Back up MAAS¶
MAAS uses standard command-line utilities for simple, familiar backups. The options described here allow you to back up either a proof-of-concept test database or a complete production MAAS installation.
Back up a POC database¶
In many proof-of-concept (POC) environments, the maas_test_db ends up serving as the foundation for production. Backing it up protects the effort you’ve already invested in setup and configuration. Fortunately, the procedure is a simple one-line command:
pg_dump maasdb -U maas -h /var/snap/maas-test-db/common/postgres/sockets > dump.sql
Be sure to use a memorable label for the dump file.
Clean reset production backup¶
The method uses pg_dumpall the entire database and make a complete snapshot of MAAS.
Back up procedure¶
Find the PostgreSQL service:
sudo systemctl list-units --type=service | grep postgres
Create backup directory:
mkdir -p <backup-path>/$(date +%s)
Dump database:
sudo -u postgres pg_dumpall -c > "<backup-path>/$(date +%s)_dump.sql"
Stop MAAS:
sudo snap stop maas
(Optional) Stop PostgreSQL:
sudo systemctl stop postgresql.service
Snap backup:
sudo snap save maas
Export snapshot:
sudo snap export-snapshot <snapshot-id> <backup-path>/$(date +%s)_snapshot
Restart services:
sudo systemctl start postgresql.service sudo snap restart maas
Restore¶
Stop MAAS & remove instance:
sudo snap stop maas && sudo snap remove maas
Restore database:
sudo -u postgres psql -f <backup-path>/<dump.sql> postgres
Import & restore snapshot:
sudo snap import-snapshot <backup-path>/<snapshot> sudo snap restore <snapshot-id>
Restart services:
sudo systemctl start postgresql.service sudo snap restart maas