Main Content

Back Up Polyspace Access Database

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-0-main container of Polyspace Access.

Note

If you run Polyspace Access version R2021b or earlier, the docker container names might be different. To view the names of currently running containers, use command docker ps --format '{{.Names}}'.

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.

Create Database Backup

When you create a database backup, the pg_dumpall utility generates a list of SQL commands that you use to 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.

  1. 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-0-main polyspace-access-web-server-0-main

  2. Generate the database backup and save it to backup_db.sql.

    docker exec polyspace-access-db-0-main pg_dumpall -U postgres > backup_db.sql
    The docker exec command runs the pg_dumpall utility inside the polyspace-access-db-0-main container. The -U specifies superuser postgres. The output of pg_dumpall is then saved as backup_db.sql.

    You can also compress the generated backup file. For instance, to create a backup and compress it using gzip, enter this command:

    docker exec polyspace-access-db-0-main pg_dumpall -U postgres | gzip > backup_db.gz

    Note

    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.

  3. 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-0-main polyspace-access-web-server-0-main

Restore Database from Backup

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.

  1. Stop the Polyspace Access ETL and Polyspace Access Web Server services. In the terminal, enter this command:

    docker stop polyspace-access-etl-0-main polyspace-access-web-server-0-main

  2. Delete 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-0-main
    databaseFolderPath 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-0-main
    docker volume rm polyspace-data
    docker volume create polyspace-data
    docker restart polyspace-access-db-0-main

  3. Restore the database from backup_db.sql. In the terminal, enter this command:

    docker exec -i polyspace-access-db-0-main psql -U postgres postgres <backup_db.sql
    If you stored your backup in a compressed file, decompress the file, and then pipe its content to the docker 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-0-main psql -U postgres postgres

  4. In 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).

Related Topics