To create a backup of your Polyspace® Access database, use the pg_dumpall PostgreSQL utility. The utility creates a dump of
your database. You can then restore the state of the database from when the dump was created.
The pg_dumpall utility is available in the
polyspace-access-db-main container of Polyspace Access.
Based on your database size and frequency of use, establish a policy for how often you create a backup. Users cannot interact with Polyspace Access while you perform a database backup or restore. Inform users before you start a backup or restore operation.
When you create a database backup, the pg_dumpall utility generates a
list of SQL commands that you use reconstruct your database. The backup operation requires
superuser privileges. The privileges are set through PostgreSQL and are separate from the
user privileges on your system. For example, to generate a database dump and save it as
backup_db.sql, open a terminal on the machine that hosts the
Polyspace Access Database service and follow these steps. This
workflow assumes that all the Polyspace Access services are running.
To ensure that your backup does not contain partial or corrupted data, stop the Polyspace Access ETL and Polyspace Access Web Server services before starting the backup operation. In the terminal, enter this command:
docker stop polyspace-access-etl-main polyspace-access-web-server-mainGenerate the database backup and save it to
backup_db.sql.
docker exec polyspace-access-db-main pg_dumpall -U postgres > backup_db.sqldocker exec command runs the pg_dumpall
utility inside the polyspace-access-db-main container. The
-U specifies superuser postgres. The output of
pg_dumpall is then saved as backup_db.sql. Be
aware that using pg_dumpall on large databases might generate files
that exceed the maximum file size limit on some operating systems and can be time
consuming. Once you complete your backup, use this command to restart the Polyspace Access ETL and Polyspace Access Web Server services.
docker start polyspace-access-etl-main polyspace-access-web-server-main
To recover your data from a database backup, use the psql utility. This utility is available in the
polyspace-access-db-main container. The operation restores the data and
the user permissions for the Polyspace Access projects. For example, you can restore your database from a backup
stored in file backup_db.sql. You complete some steps in the
Cluster Admin interface. Other steps require a terminal on the server
that hosts the Polyspace Access Database service. On Linux, you might
need superuser privileges to complete this operation.
Stop the Polyspace Access ETL and Polyspace Access Web Server services. In the terminal, enter this command:
docker stop polyspace-access-etl-main polyspace-access-web-server-mainDelete the folder that stores the Polyspace Access database, and then restart the Polyspace Access Database service.
sudo rm -rf databaseFolderPath
docker restart polyspace-access-db-maindatabaseFolderPath
is the folder path that you specify in the Data volume field of
the Polyspace Access Database service in the Admin Cluster
Settings, for example:/local/Polyspace/R2020b/appdata/polyspace-access/db
If you specify a volume name instead of a folder path in the Data
volume field, for example polyspace-data, use these
commands to stop the database service, delete the volume, create a new volume, and
restart the database
service:
docker stop polyspace-access-db-main
docker volume rm polyspace-data
docker volume create polyspace-data
docker restart polyspace-access-db-mainRestore the database from backup_db.sql. In the terminal, enter
this
command:
docker exec -i polyspace-access-db-main psql -U postgres postgres <backup_db.sqldocker exec command. For instance, if you use
gzip, use this command to restore the database from file
backup_db.gz.gzip -cd backup_db.gz | docker exec -i polyspace-access-db-main psql -U postgres postgresIn the Cluster Admin interface, click Restart Apps to start all the services.
After the services start, open the Polyspace Access interface in your web browser to view the projects that were stored in the database when you created the backup.
Alternatively, you can rely on write ahead log (WAL) files to perform incremental backups and recoveries of your database. The WAL records all changes made to the database. The system stores only a few WAL files and recycles older files.
By creating a base backup and storing all subsequent WAL files, you can restore your database by replaying the WAL sequence up to any point between when you made your base backup and the present. For an example of how to configure an incremental backup, see Continuous Archiving and Point-in-Time Recovery (PITR).