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

Backing 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

  1. Database backup: Run sudo -u postgres pg_dumpall -c > ~/dump.sql to back up your database.
  2. Active sessions: Confirm no other sessions are active with sudo -u postgres psql -c "SELECT * FROM pg_stat_activity".

Stopping services

  1. Stop PostgreSQL: sudo systemctl stop postgresql.service
  2. Stop MAAS: sudo snap stop maas

Snapshot and export

  1. Take snapshot: Run sudo snap save maas and note the snapshot ID.
  2. Verify snapshot: Check the snapshot with sudo snap check-snapshot <snapshot-id>.
  3. Export snapshot: Use sudo snap export-snapshot <snapshot-id> <external-media-path/snapshot-filename> to save it externally.

Restart and restore

  1. Restart: If continuing to use the system, restart MAAS with sudo snap restart maas.
  2. Clean slate: To reinstall, remove the old instance with sudo snap remove --purge maas.
  3. Restore database: Use sudo -u postgres psql -f dump.sql postgres to restore the database dump.
  4. Restore snapshot: Import and restore the snapshot with sudo snap import-snapshot <external-media-path/snapshot-filename> and sudo snap restore <snapshot-id>.

For package installations

Preliminaries

  1. Database backup: Same as above.
  2. Active sessions: Same as above.

Stopping services

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

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

  1. Initial setup: Begin with a fresh Ubuntu install.
  2. Stop services: Similar to the stopping services step above.
  3. Untar backup: Use sudo tar xvzpf backup.tgz to extract the backup.
  4. Restore database: Same as above.

Copy configs and restart

  1. Move old configs: Use sudo sh -c "mv /etc/maas /etc/_maas; mv /var/lib/maas /var/lib/_maas".
  2. Restore new configs: Use sudo sh -c "cp -prf etc/maas /etc/; cp -prf var/lib/maas /var/lib/".
  3. 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.