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

How to back up MAAS

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 the PostgreSQL service:
sudo systemctl stop postgresql.service
  1. Stop the MAAS snap service:
sudo snap stop maas
  1. Take a snapshot of the snap service:
sudo snap save maas

Note the snapshot id (number) that this command returns.

  1. Verify that the snapshot is valid:
sudo snap check-snapshot <snapshot-id>
  1. Export the snapshot to some external media:
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.

  1. If reinstalling MAAS on the same system, use the following command to completely remove the old MAAS instance from your system:
sudo snap remove --purge maas
  1. Restore the PostgreSQL dump with the following command:
sudo -u postgres psql -f dump.sql postgres
  1. Restart the PostgreSQL service:
sudo systemctl start postgresql.service
  1. Install the MAAS snap (same version) on your target machine, using the standard installation instructions for the version you're (re)installing.

  2. 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.

  1. Restore the snapshot:
sudo snap restore <snapshot-id>
  1. Reset the database triggers with the following command:
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.