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 snap stop maas
sudo snap save maas
Note the snapshot id (number) that this command returns.
sudo snap check-snapshot <snapshot-id>
sudo snap export-snapshot <snapshot-id> <external-media-path/snapshot-filename>
Be sure to restart the MAAS service if you plan to continue to use the current configuration, with:
sudo snap restart maas
Otherwise, you can leave MAAS stopped.
sudo snap remove --purge maas
sudo -u postgres psql -f dump.sql postgres
sudo systemctl start postgresql.service
Install the MAAS snap (same version) on your target machine, using the standard installation instructions for the version you're (re)installing.
Import the snapshot onto your target machine:
sudo snap import-snapshot <external-media-path/snapshot-filename>
The import function should give you the same snapshot ID. If an existing snapshot has the same number (shouldn't happen here), that snapshot is overwritten.
sudo snap restore <snapshot-id>
sudo maas-region dbupgrade
[note] You only need to run this command on one of the Region Controllers in a multi-region MAAS cluster. [/note]
At this point, you should be up and running with a restored MAAS backup.