Migrate existing installations to a different machine and never Python 3 version

I want to migrate existing and working Octoprint installations to another system. Both run Ubuntu Linux, but the target system runs Python 3.11.x, while the existing system uses Python 3.8.x

Obviously I need to copy all the config files and other files that are not part of the Python virtualenv.

Then I wanted to get all the packages to install them on the target system (after creating a new virtualenv).

On the existing machine

$ source ~/venvs/octoprint1/bin/activate
$ pip list --format=freeze > requirements.txt

On the target system

$ python3 -m venv ~/venvs/octoprint1
$ source ~/venvs/octoprint1/bin/activate
$ pip install -r requirements.txt

This works for a short while but then I get an error

ERROR: Could not find a version that satisfies the requirement command-not-found==0.3 (from versions: none)
ERROR: No matching distribution found for command-not-found==0.3

I also had issues with other Python software migrating this way, it seems exporting the package names and versions doesn't seem to work (sometimes?). Usually I end up install the software new. But since there are quite a lot of plugins I wanted somehow to carry them over to the new installation.

Is there a better or recommended way of doing this? I also tried pip freeze, but that was even worse, because it creates sometimes URLs instead of package version numbers.

Hello @neo2001 !

I would recommend to make a backup of the running machine and use that as a start for a new installed OctoPrint server. (E.g. with the paukstelis script by @paukstelis )

Migrating a complete running environment won't be that easy - if not even impossible.

The script installs the appropriate Python version into the virtual environment of OctoPrint

I would recommend taking a backup inside your existing OctoPrint installs. That keeps your data & plugins. Then all you have to do from the Python side is just pip install octoprint (or follow the aforementioned script for the whole process) and you will get a fresh environment, then restore your backup - and you get back to where you were OctoPrint-wise. I would probably recommend against requirements.txt type backups to avoid dependency conflicts.

Thank you both for your replies!

I completely forgot to check for a integrated Backup & Restore function. Of course, this makes a lot more sense to use! I created a new virtualenv on the target system and then restored the file by uploading it. Octoprint then immediately installed the plugins and everything seems fine now.

Thanks!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.