About Database Backup and Restore

This page covers how to back up and restore individual GroundWork 8 databases. The GroundWork 8 databases contain your data, and you may want to extract that data for your own purposes, or to move it to another server for testing or development reasons. We sometimes use copies of databases to share example configurations, test solutions for support cases, and other ad-hoc work with data and analysis. These procedures are provided so that you can do so as needed. 

These procedures use the gwadmin account to perform the backup and restore processes. This is a privileged account in GroundWork 8 and the authentication information is hidden in a secure file in the container file system. The default credential is just gwadmin. If you do decide you need to change this password, please Submit a Ticket.

The backup procedure will produce a backup file on the host, owned by root. The backup file can be renamed to suit. Backup files should be stored (manually moved) outside the volatile /tmp directory. To be restored, the backup files will need to be copied back into the /tmp directory.

Database Backup

  1. Change to the gw8 directory:

    cd gw8
    CODE
  2. The monitoring system doesn't need to be down to create an individual database backup, but you might want to have it be down to ensure a completely consistent state on restore. To optionally take GroundWork down:

    docker-compose down
    CODE
  3. To backup a single database from a running GroundWork system, run the following commands, specifying the database to back up listed here:

    Supported databases include:

    • archive_gwcollagedb
    • dalekstore
    • elastic
    • gwcollagedb
    • influxdb
    • jasperserver
    • monarch
    • nedi
    • nedi_nodes
    • noma
    • report_db
    • slareport
    For the specification of the SERVER_NAME, this is optional (it is only required to name the backup files).
    TAG=$(grep '^TAG=' .env | sed 's/^TAG=//')
    SERVER_NAME=$(hostname -f)
    docker run -it --rm \
        --network=default \
        -v /var/run/docker.sock:/var/run/docker.sock \
        -v ${HOME}/.docker:/root/.docker \
        -v /tmp:/tmp/tmp \
        --name gw8 groundworkdevelopment/gw8:${TAG} \
        /src/docker_cmd.sh backupDatabase <database> [-s $SERVER_NAME]
    • Enter the gwadmin password when prompted. The resulting file name is of the form e.g., monarch: /tmp/dockergw8-backup-monarch-20200420205424.sql.gz

  4. To backup a single database from a stopped GroundWork system, run the following commands, specifying the database to back up

    TAG=$(grep '^TAG=' .env | sed 's/^TAG=//')
    SERVER_NAME=$(hostname -f)
    docker run -it --rm \
        -v /var/run/docker.sock:/var/run/docker.sock \
        -v ${HOME}/.docker:/root/.docker \
        -v /tmp:/tmp/tmp \
        --name gw8 groundworkdevelopment/gw8:${TAG} \
        /src/docker_cmd.sh backupDatabase <database> [-s $SERVER_NAME]
    • Enter the gwadmin password when prompted.

  5. If you brought it down, bring GroundWork up:

    docker-compose up -d
    CODE

Database Restore

  1. First make sure you have a running install of a version of GroundWork Monitor that is compatible with your backup. If backups made from previous versions are restored, migrations will have to be run again by reinstalling the more recent version.
  2. To restore, place the backup file you want to restore in the /tmp directory on the host (this is where the container loads it from), symlinks are not supported:
    • Change to the gw8 directory:

      cd gw8
      CODE
    • To restore, GroundWork must be stopped. Take GroundWork down:

      docker-compose down
      CODE
  3. Set up and run the restore from the gw8 container with the following command:

    TAG=$(grep '^TAG=' .env | sed 's/^TAG=//')
    docker run -it --rm \
        -v /var/run/docker.sock:/var/run/docker.sock \
        -v ${HOME}/.docker:/root/.docker \
        -v /tmp:/tmp/tmp \
        --name gw8 groundworkdevelopment/gw8:${TAG} \
        /src/docker_cmd.sh restoreDatabase <database> <database backup file path>
    CODE
    • Enter the gwadmin password when prompted.

  4. Bring GroundWork up:

    docker-compose up -d
    CODE

Related Resources