Moving Moonraker to/from a Pi

By | December 19, 2021

If you like to tinker, like I do, you may find yourself doing crazy things like loading Klipper on your Linux laptop and running out of time to move it to Raspberry Pi so you end up printing for over 150 hours on it. After getting tired of having to have the laptop hooked up to the printer, you decide it's time to finally finish what you started and move it to the Pi. Simple, right?

Nope.

I'll cover the big steps here and then I'll delve into a little more detail with regards to the topic of this blog, which is the Moonraker database.

First, to move klipper, you'll need to prep the Pi as normal and then copy over the contents of your klipper_config folder from the other system to the Pi. If the other system is the same architecture (Pi to Pi, 32-bit to 32-bit, 64-bit to 64-bit, etc.) the Moonraker database will copy over without issue. If, however, you're changing architectures completely, you'll need to use some additional steps:

  1. You'll need to got to your source machine and stop Moonraker (sudo service moonraker stop).
  2. Next, go to the Moonraker database location, which is usually ~/.moonraker_database (cd ~/.moonraker_database)
  3. Install the lmdb-tools package: sudo apt-get install lmdb-tools
  4. Use mdb_dump to dump the database to a file: mdb_dump -f moonraker.txt -a . (the period at the end matters)
  5. Now, copy moonraker.txt to the new machine and store it in the Moonraker database directory (we won't cover that here)
  6. On the new machine, stop the Moonraker service
  7. Rename the data.mdb and lock.mdb to data.old and lock.old (mv data.mdb data.old)
  8. Now start the Moonraker service and immediately stop it (this creates blank, fresh databases)
  9. Install the lmdb-tools package on the new machine (see above)
  10. Use mdb_load to load the data: mdb_load -f moonraker.txt .
  11. Start the moonraker service and you should be good to go!