Skip to main content

Backups and restores (Linux w/ Docker)

How to back up and restore the Informer PostgreSQL database from the terminal on a Docker deployment.

What should I back up?

Informer has four main components:

  • Informer: where the application itself lives.
  • Elasticsearch: where Datasets are indexed and stored.
  • PostgreSQL: where the Informer metadata, system settings, and workspaces are stored.
  • Redis: where cached elements of the application are stored.

At a minimum, back up the PostgreSQL database, since it is the only component that cannot be easily recovered. You may also want to back up Elasticsearch so you do not have to refresh every Dataset after a restore; see the Elasticsearch snapshots documentation for how.

Stop components before restoring

All Informer components except PostgreSQL must be stopped before restoring from backup, or you risk corrupt data.

Defaults used here

These commands use the default Postgres username (i5) and database name (i5), and assume the backup is a file named backup_all.sql. If your values differ, adjust the commands.

Backing up PostgreSQL

The supported method is the terminal. (You can also copy the PostgreSQL data files or use a snapshot procedure, but this article covers the terminal method.)

Backs up all databases

This method backs up every database in the PostgreSQL container. If PostgreSQL serves other applications and you do not want to back them all up, contact Support for alternative methods.

  1. Stop all your containers:

    docker-compose stop
  2. Start just the PostgreSQL container:

    docker-compose start postgres
  3. Create a backup file inside the PostgreSQL container:

    docker-compose exec postgres pg_dumpall -c -U i5 -f ./backup_all.sql
    Password prompts

    This command may prompt for a password once per database on the server, so with password authentication you may type it several times.

  4. Copy the backup file from the container to the host:

    docker cp <psql_container_name>:./backup_all.sql ./backup_all.sql

    The default PostgreSQL container name is based on your installation directory. For example, if Informer is installed in /home/user/Informer5, the container is informer5_postgres_1; if it is in /home/user/I5, the container is i5_postgres_1.

  5. Verify the backup file has contents, by opening it or checking the file size.

If you back up by another method, the default location of the PostgreSQL data files is /var/lib/postgresql/data.

Restoring PostgreSQL

  1. Make sure the Informer containers are stopped.

  2. In a terminal, navigate to the folder with your backup file.

  3. Copy the backup file into the PostgreSQL container:

    docker cp ./backup_all.sql <psql_container_name>:./backup_all.sql

    (The container name follows the same convention as above.)

  4. Restore the backup:

    docker-compose exec postgres psql -U i5 -f ./backup_all.sql

If you backed up by a method other than the one above, restore using that same method.

Restoring over existing data

When restoring onto a system that already has PostgreSQL data, replace step 4 above with the following.

Step into the PostgreSQL container:

docker-compose exec postgres bash

Open a psql prompt:

psql -U i5

Create a superuser called postgres:

create user postgres superuser;

Quit the psql prompt and exit the container:

quit
exit

Then, from the host, run the restore as the postgres user:

docker-compose exec postgres psql -U postgres -f ./backup_all.sql