How to back up MAAS
While MAAS doesn’t offer specialised backup tools, you can rely on your existing backup solutions. Know the key files and procedures to ensure both a clean backup and a smooth restoration.
For snap installations
Preliminaries
-
Database backup: Run
sudo -u postgres pg_dumpall -c > ~/dump.sql
to back up your database. -
Active sessions: Confirm no other sessions are active with
sudo -u postgres psql -c "SELECT * FROM pg_stat_activity"
.
Stopping services
-
Stop PostgreSQL:
sudo systemctl stop postgresql.service
-
Stop MAAS:
sudo snap stop maas
Snapshot and export
-
Take snapshot: Run
sudo snap save maas
and note the snapshot ID. -
Verify snapshot: Check the snapshot with
sudo snap check-snapshot <snapshot-id>
. -
Export snapshot: Use
sudo snap export-snapshot <snapshot-id> <external-media-path/snapshot-filename>
to save it externally.
Restart and restore
-
Restart: If continuing to use the system, restart MAAS with
sudo snap restart maas
. -
Clean slate: To reinstall, remove the old instance with
sudo snap remove --purge maas
. -
Restore database: Use
sudo -u postgres psql -f dump.sql postgres
to restore the database dump. -
Restore snapshot: Import and restore the snapshot with
sudo snap import-snapshot <external-media-path/snapshot-filename>
andsudo snap restore <snapshot-id>
.
For package installations
Preliminaries
- Database backup: Same as above.
- Active sessions: Same as above.
Stopping services
-
Stop services: Use
sudo systemctl stop postgresql.service; sudo systemctl stop maas-dhcpd.service; sudo systemctl stop maas-rackd.service; sudo systemctl stop maas-regiond.service
.
Archival
-
Archive: Use
sudo tar cvpzf <some-external-path>/backup.tgz --exclude=/var/lib/maas/boot-resources /etc/maas /var/lib/maas ~/dump.sql
to archive essential files and DB dump.
Restoration steps
- Initial setup: Begin with a fresh Ubuntu install.
- Stop services: Similar to the stopping services step above.
-
Untar backup: Use
sudo tar xvzpf backup.tgz
to extract the backup. - Restore database: Same as above.
Copy configs and restart
-
Move old configs: Use
sudo sh -c "mv /etc/maas /etc/_maas; mv /var/lib/maas /var/lib/_maas"
. -
Restore new configs: Use
sudo sh -c "cp -prf etc/maas /etc/; cp -prf var/lib/maas /var/lib/"
. - Restart services: Similar to the restart steps in the Snap installations.
With these steps, you’ll be able to backup and restore your MAAS environment effectively.
Last updated 24 days ago.