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:
dump.sql
in your home directory:sudo -u postgres pg_dumpall -c > ~/dump.sql
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.
sudo systemctl stop postgresql.service
sudo systemctl stop maas-dhcpd.service
sudo systemctl stop maas-rackd.service
sudo systemctl stop maas-regiond.service
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.
To restore the MAAS backup to a new machine:
Start with a freshly-updated installation of Ubuntu on identical hardware.
Reinstall MAAS via the standard installation procedure.
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
sudo tar xvzpf backup.tgz
sudo -u postgres psql -f dump.sql postgres
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.
If your restore process regenerated the /var/lib/maas/secret
file, make sure update this secret on any additional rack controllers.
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.
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.