Backup Python 3.12 environment on RHEL 8 VM

Hi everybody!
I search this topic but I found nothing here. I want to backup Python 3.12 installation on RHEL 8 running on VM. I have a few virtual environment, each with it’s requirements.txt (list of packages). What is the best way to backup the hole thing, excluding user files.

I don’t know if this is the “everything” you need, but you can use pip freeze.

Thank you Franklinvp for your reply!
I already have it in the requirements.txt. This file has backup, the point is to avoid downloading all the packages in case of recovery.

Then you should make sure you understand the download caching already built in to Pip, and how to work with it.

Thank you Karl.
Caching seams great in case of python crash, but if the o.s. crashs…
However, in the page there’s a link [Installing from local packages] that made me change the aproach. I saved all the packages on my Satellite storage and in the requirements.txt, for each vm, I have the path to the local packages.

That seams to work for me, but if anyone has an alternative option I would love to hear it!
Thanks a lot !!!

I posted two links, but it seems only the second one got a fancy summary box automatically.

What I was trying to get at is, because Pip uses this cache by default, you already had a sort of “backup” automatically. By understanding how the cache works, you can copy the wheels out of it, and those are your backup (it’s a lot more practical than trying to back up the unpacked site-packages folders). And by maintaining a folder of those wheels, you have a source that you can use to “restore the backup” (really, just install locally - the same is equally useful if you want to clone environments, or have another reason to work offline). Of course, you won’t get updates (including for security) this way.

Hey Karl, thanks once again! This is an interesting option.

Last week I was too busy but this week I am going to try this. I will simulate both restores, from packages backup, refered in the requirements.txt and from cache backup ( http-v2 folder).

I will post here the results.