Transfer Portainer to a different host

Logo for the product Portainer

I use the product Portainer to manage the various docker containers I have at home. Periodically, I change my infrastructure set up, which results in my having to transfer the Portainer containers to a different server.

This time, I have decided to document what I did, in an attempt to not have to recreate the wheel next time I need to perform this activity.

  1. Check you have the command line for starting Portainer.
    • Obviously, you will need this to start up portainer when it gets where it is going.
  2. Make a volume on the new host.
    • This will hold a copy of the persisted Portainer data.
  3. Stop portainer on the old host
  4. Backup the old volume on the old host.
    • You’ll likely need to be root to view the folder correctly.
  5. Transfer the backed up file to the new host using scp.
  6. Restore the backup file into the volume on the new host.
    • You’ll likely need to be root to get the permissions correct.
  7. Startup portainer using the volume
    • At this point the transfer of Portainer is technically complete.
  8. Test you can connect to portainer.
  9. Startup portainer agent on the old host.
    • This is so that I have access to the old host again.
      I’m going to need this to clean up the old host.
  10. Redirect the proxy.
    • I use NPM and I needed to fix the proxy to fetch portainer from the new host.
  11. Clean up stacks
    • In this situation i am moving to a new Lab server, so I have copied stacks from the old host to the new host, manually backing up and transferring volumes as required.