Offline docs (switch to live docs)                         UI-only         CLI-only

How to keep MAAS backed up

MAAS currently does not provide specific tools to back up and restore a working MAAS configuration. MAAS servers are part of your data centre, just like other Linux-based servers, so your current backup and disaster recovery solution should be sufficient to back up your MAAS environment. Even so, you should know which files and actions are critical – to ensure that you get a clean backup, and further ensure that you can restore it cleanly.

To back up your MAAS snap instance and restore it elsewhere, follow these steps:

  1. Backup your PostgreSQL database to a file called dump.sql in your home directory:
sudo -u postgres pg_dumpall -c > ~/dump.sql
  1. Ensure this has completed and that there are no other established sessions with the following command:
sudo -u postgres psql -c  "SELECT * FROM pg_stat_activity"

Running sessions, such as pg_dumpall, will appear in the application_name column of the output alongside psql running the above pg_stat_activity query.

  1. Stop MAAS-related services:
sudo systemctl stop postgresql.service
sudo systemctl stop maas-dhcpd.service
sudo systemctl stop maas-rackd.service
sudo systemctl stop maas-regiond.service
  1. Archive the DB backup and the needed MAAS configuration files to an external drive with the following command:
sudo tar cvpzf <some-external-path>/backup.tgz --exclude=/var/lib/maas/boot-resources /etc/maas /var/lib/maas ~/dump.sql

If you’re not replacing the existing MAAS, make sure to restart the services you stopped prior to completing the backup.

How to restore the system when needed

To restore the MAAS backup to a new machine:

  1. Start with a freshly-updated installation of Ubuntu on identical hardware.

  2. Reinstall MAAS via the standard installation procedure.

  3. Stop the following services (note that PostgreSQL needs to keep running):

sudo systemctl stop maas-dhcpd.service
sudo systemctl stop maas-rackd.service
sudo systemctl stop maas-regiond.service
  1. Copy the backup file to the new machine and untar its contents:
sudo tar xvzpf backup.tgz
  1. Restore the database with the following command:
sudo -u postgres psql -f dump.sql postgres
  1. Copy across the old configuration files to their new locations, taking care to move the originals aside just in case:
sudo sh -c "mv /etc/maas /etc/_maas; mv /var/lib/maas /var/lib/_maas"
sudo sh -c "cp -prf etc/maas /etc/; cp -prf var/lib/maas /var/lib/"

Take care to preserve the correct permissions when restoring files and directories.

  1. If your restore process regenerated the /var/lib/maas/secret file, make sure update this secret on any additional rack controllers.

  2. Reset the database triggers:

sudo maas-region dbupgrade

NOTE: You only need to run this command on one of the Region Controllers in a multi-region MAAS cluster.

  1. Restart the stopped services:
sudo systemctl start maas-dhcpd.service
sudo systemctl start maas-rackd.service
sudo systemctl start maas-regiond.service

At this point, you should be up and running with a restored MAAS backup.