NAV Navbar
Switch version:

Backup And Restore Postgres Database

This section describes the backup and restore process for GoCD with Postgres Database. For performing GoCD server backup follow the steps provided in our documentation here.

What Is Backed Up?

GoCD one-click backup will be performed into the {ARTIFACT_REPOSITORY_LOCATION}/serverBackups directory. {ARTIFACT_REPOSITORY_LOCATION} for your server can be found as mentioned here.

The backup directory will be named backup_{TIMESTAMP} where the {TIMESTAMP} is the time when the backup was initiated.

  1. Database – Postgresql database is backed up in a file called {}.sql or {}.sqlc based on the backup format configured via {db.backup.format}. The values for properties {} and {db.backup.format} can be obtained from file on the GoCD server being backed up. Please refer the Add-on configuration reference section.

  2. Configuration – This is in a zip called This zip contains the XML configuration, Jetty server configuration, Keystores and all other GoCD’s internal configurations.

  3. XML Configuration Version Repo – This is in a zip called . This zip contains the Git repository of the XML configuration file.

  4. GoCD version – This is a file called version.txt. This file contains the version of the GoCD server when the backup was initiated

What is not backed up?

The following are not backed up as a part of the GoCD backup process. Please ensure that these are manually backed up regularly.

Restore Postgres Database Backup

This section describes how to restore Postgres database backup alone. For performing a full GoCD server restore follow the steps provided in our documentation here.

Step 1: Create an empty database

Currently, Postgres versions 9.3 to 9.6, 10.11, 11.6 and 12.1 are tested and supported by GoCD, older versions are not supported. If the Postgres server is not yet initialized, it needs to be, before GoCD is able to use it. Along with PostgreSQL server, you need to install postgresql-client and postgresql-contrib packages.

Once initialized and the Postgres service is started, the empty database can be created from the command-line using the psql utility, which Postgres ships with:

$ psql -U postgres -h localhost -c "CREATE DATABASE cruise-or-desired-database-name ENCODING="UTF8" TEMPLATE="template0";"

The GoCD Server uses cruise as the default database name. The database name chosen can be that, or any other valid Postgres database name. While configuring the GoCD Server in a later step, the chosen name can be configured.

Step 2: Restore the backup file

The GoCD server backup contains the database backup file {}.sqlc. The database can be restored using the following command:

Please ensure the restore user has the required permissions as explained here.

$ pg_restore --host=<host> --port=<PORT> --username=<USER> --format=custom --exit-on-error --single-transaction --dbname=<DBNAME> <FILE>.sqlc
$ psql --set ON_ERROR_STOP=on --single-transaction --host=<HOST> --port=<PORT> --username=<USER> <backup_db_name> -f <FILE.sql>

Step 3: Update file to point to new postgres database

The location of GoCD’s installation directory varies per operating system. The documentation provides information about the locations. Usually, on a Linux system using the RPM or Debian installers, this file will need to be at /etc/go/

Step 4: Start GoCD server

Please ensure all steps mentioned in our documentation here are completed along with the above steps before you start the GoCD server.

The GoCD Server can now be started.

On Linux:

$ service go-server start

On Windows:

C:\> net start "Go Server"


$ psql --dbname=<your_db_name> -U <db_user_name>
$ postgres=# \du

Use the following command to check for postgres server version

$ postgres -V

Use the following command to check for postgres client version

$ psql -V