Back Up or Restore a Polarity Server
  • 06 Feb 2026
  • 1 Minute to read
  • Dark
    Light
  • PDF

Back Up or Restore a Polarity Server

  • Dark
    Light
  • PDF

Article summary

How to back up and restore a standard Polarity Server v5 system on the Polarity Server’s command line.

Polarity Server Backups

The Polarity Server runs a cron job daily at midnight (system time) to back up the following components:

  • The Polarity database (schema and data dumps)

  • The .env file

  • All installed integrations

These backups are place in the /app/backups directory by default, and are named in this format:

polarity-server-backup-YYYYMMDDhhmmss.tgz

where:

  • YYYY is the 4-digit year

  • MM is the 2-digit month

  • DD is the 2-digit day of the month

  • hh is the 2-digit hour of the day (in 24-hour time format)

  • mm is the minute of the hour

  • ss is the seconds

Manual Backups

The Polarity Command Line Utility may be used to create a manual backup in the same format, on demand.

To initiate a manual back up:

  1. Log into the Polarity Server’s back end operating system command line as the root user or a user with sudo privileges.

  2. Change working directories to the /app directory:

    1. cd /app

  3. Execute the Polarity Server backup command:

    1. bin/polarity backup

    2. This command will assess the current state of the system and create a backup file, as described above.

Restoring Polarity Server Backups

A Polarity Server backup file may be restored using the same Polarity Command Line Utility.

  1. Log into the Polarity Server’s back end operating system command line as the root user or a user with sudo privileges.

  2. Change working directories to the /app directory:

    1. cd /app

  3. Execute the Polarity Server restore command:

    1. bin/polarity restore /absolute/path/to/polarity-server-backup.tgz

    2. This command will:

      1. Drop the currently-loaded Polarity database

      2. Restore the database in the backup file

      3. Replace the database-related variables in the .env file with those from the backup file

      4. Restore the integrations from the backup file

  4. Upon successful completion of this restore process, restart the Polarity Server containers:

    1. cd /app && ./down.sh && ./up.sh

Note

If you receive an error during the restore process warning that one or more roles do not exist in the database, simply create the role(s) with the following command:

source /app/.env && psql -h $POLARITY_DB_HOST -U $POLARITY_DB_USER -d $POLARITY_DB_DATABASE -c “create role [MISSING_ROLE];”

where [MISSING_ROLE] is replaced with the role indicated by the error.

After this, attempt the restore process again.


Was this article helpful?