Backing Up and Restoring a Concourse Database

Backing up Concourse databases is a best practice that helps protect pipelines, build history, and team information over time. Pivotal recommends that you schedule periodic backups of your Concourse database, before and after updates, or after other substantial changes.

You can also use backed up versions of databases to restore database states after unexpected problems, like database failure, corruption, or interference from malicious third parties. Specifically, the backup and restore process restores build history, pipelines, and team information. It cannot restore builds that were running at the time of backup.

A Concourse database is a PostgresSQL database that can be internal (deployed from the Concourse BOSH release) or external (configured with Concourse).

For complete backup and restore procedures refer to the documentation for your version of PostgresSQL database. For example: https://www.postgresql.org/docs/9.1/static/backup.html.

This topic provides a sample backup and restore procedure for an internal Concourse PostgresSQL database.

Backing Up a Concourse Database

This procedure explains how to back up a Concourse database deployed from the Concourse BOSH release.

  1. SSH into your database VM. You may want to use BOSH SSH.
  2. Open a terminal window.
  3. Locate the Postgres binaries on your VM by entering the following command:
    ps aux | grep postgres
    
    The binary location displays.
  4. Switch to the vcap user. This user has permissions to use the backup and restore commands.
    sudo su vcap
    
  5. Navigate to the root directory.
    cd ~
    
  6. Enter the command to generate a backup file:
    POSTGRES-BINARY-LOCATION/pg_dumpall -c -f /FILEPATH/BACKUP-FILE-NAME
    
    When you generate the backup file, you can use any name and any file extension. For example: “january-backup.txt”.

    Note: The -c flag will wipe any unsaved data on the database. When you back up the database, check to be sure you have saved any important data.

  7. Extract the backup file from the VM. You may want to use BOSH SCP.
  8. Store the backup file somewhere secure.

Restoring a Concourse Database

Once you generate a backup file, you can apply it to a database to restore a previous state. Do not use a backup file to overwrite an existing database. Overwriting databases leads to data loss, and may lead to total deployment failure. Only apply a backup to a new database.

Follow the steps below to restore a Concourse database.

  1. Insert your backup file into the database VM. You may want to use BOSH SCP.
  2. SSH into your database VM. You may want to use BOSH SSH.
  3. Locate the Postgres binaries on your VM by entering the following command:
    ps aux | grep postgres
    The binary location displays.
  4. Switch to the vcap user. This user has permissions to use the backup and restore commands.
    sudo su vcap
  5. Navigate to the root directory.
    cd ~
  6. Apply the backup file to the database.
    psql -f BACKUP-FILE-NAME
Create a pull request or raise an issue on the source for this page in GitHub