How do I backup my OctoPrint settings on OctoPi?

Starting with 1.3.10 OctoPrint will ship with a bundled Backup Plugin that should make backing up and restoring settings, files and plugins easy.


For versions prior to that, read on:

OctoPrint stores all its data in ~/.octoprint - uploads, timelapses, configuration, plugin data, etc. That makes backing them up quite easy. Third party plugins are installed into the virtual environment under ~/oprint and a bit trickier to backup since you can't just copy that folder (well, technically you could, but stuff wouldn't necessarily work...).

The following backup/restore procedure should work:

Backup

  • Create a list of installed plugins. This can be done by either going into Settings->Plugin Manager or logging in via SSH and referencing the octoprint log file. If using SSH, open up ~/.octoprint/logs/octoprint.log or ~/.octoprint/logs/octoprint.log-YYYY-MM-DD with a text editor. Somewhere in there should be something that looks like this:

    2017-11-07 12:50:02,100 - octoprint.plugin.core - INFO - 19 plugin(s) registered with the system:
    |  Announcement Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.5-py2.7.egg/octoprint/plugins/announcements
    |  Core Wizard (bundled) = /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.5-py2.7.egg/octoprint/plugins/corewizard
    |  Cost Plugin (0.1.3) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_cost
    |  CuraEngine (<= 15.04) (bundled) = /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.5-py2.7.egg/octoprint/plugins/cura
    |  Custom Control Editor (0.2.1) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_customControl
    |  Discovery (bundled) = /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.5-py2.7.egg/octoprint/plugins/discovery
    |  DisplayProgress (0.1.2) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_displayprogress
    |  FileManager (0.1.2) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_filemanager
    |  Find My OctoPrint (0.1.0) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_findmyoctoprint
    |  Firmware Updater (0.2.0) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_firmwareupdater
    |  Fullscreen Plugin (0.0.3) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_fullscreen
    |  Plugin Manager (bundled) = /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.5-py2.7.egg/octoprint/plugins/pluginmanager
    |  PortLister (0.1.6) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_portlister
    |  Pushbullet (0.1.9) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_octobullet
    |  Software Update (bundled) = /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.5-py2.7.egg/octoprint/plugins/softwareupdate
    |  Telegram Notifications (1.4.2) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_telegram
    |  TouchUI (0.3.10) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_touchui
    |  Virtual Printer (bundled) = /home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.5-py2.7.egg/octoprint/plugins/virtual_printer
    |  Yamlpatcher (0.1.1) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_yamlpatcher
    

    Note down each plugin that is installed.

  • Shut down your OctoPrint server: sudo service octoprint stop

  • Using an SCP client (e.g. something like scp or WinSCP) on your computer, backup the whole ~/.octoprint folder. If you are using WinSCP, you'll need to first hit Ctrl+Alt+H to make it show up. For your backup, make sure to preserve timestamps, also for directories (scp -p ..., in WinSCP make sure to check "Preserve Timestamps" and "Including Directories" in your transfer profile under Options > Preferences > Transfer).

  • Restart your OctoPrint server: sudo service octoprint start

Restore

  • Log in via SSH, shut down your OctoPrint server: sudo service octoprint stop
  • Using your SCP client, log into the image. Delete the current .octoprint folder. Then copy back your backup of .octoprint that you made earlier. Again, make sure to preserve timestamps of files and directories.
  • Log into the image via SSH, restart your OctoPrint server: sudo service octoprint start
  • You should now be able to open up OctoPrint in your browser and log back in just like before.
  • However, your plugins are still missing. Open Settings > Plugin Manager > Get More... and install all plugins that don't have a bundled next to them from the list created during the backup. Once that's completed, you should be done.
8 Likes

And for those of us who's preference is to backup the entire card to a single local file:

backup
sudo dd if=/dev/sdX of=~/SDCardBackup.img

restore
sudo dd bs=4M if=~/SDCardBackup.img of=/dev/sdX

Cloning the sdcard onto another one is also very effective and simple.

The following command will display the collection of installed plugins from your latest octoprint.log file, making that earlier step easier:

$ cat ~/.octoprint/logs/octoprint.log | grep "|" | grep "= /home/pi/" | sort | uniq
|  Announcement Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/announcements
|  Bed Visualizer (0.1.0) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_bedlevelvisualizer
|  Core Wizard (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/corewizard
|  CuraEngine (<= 15.04) (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/cura
|  Discovery (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/discovery
|  EEPROM Marlin Editor Plugin (1.2.1) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_eeprom_marlin
|  GCODE System Commands (0.1.1) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_gcodesystemcommands
|  Logging (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/logging
|  OctoPi Support Plugin (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/octopi_support
|  Plugin Manager (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/pluginmanager
|  Printer Safety Check (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/printer_safety_check
|  Software Update (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/softwareupdate
|  Themeify (1.2.0) = /home/pi/oprint/local/lib/python2.7/site-packages/octoprint_themeify
|  Virtual Printer (bundled) = /home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/virtual_printer

I am trying to do a backup but there's insufficient space on the card.
Is there a way to
1 Find out how much space is needed
2 Back up to a different location

Thanks

Go into OctoPrint -> Settings -> Webcam & Timelapse, review the timelapse videos there and download then delete the biggest ones. This should give you some room to do the Backup routine that's also in Settings.

Or just don't include the timelapses (and maybe the uploaded files) in the backup.

I tried to run example command from docs on fresh install:

pi@octopi:~ $ octoprint plugins backup:restore --help
-bash: octoprint: command not found

How to run this?

# first...
source ~/oprint/bin/activate
# second... whatever command you tried before
1 Like

I'm going to add this link here for any other poor souls that were fighting backup/restore issues when using docker. Hint : plugins are not fun with docker

You could also use awk which leave the time prefix on so you can check it's the latest

$ cat ~/.octoprint/logs/octoprint.log | awk '/octoprint.plugin.core/,/Prefix legend/'
1 Like