Backups and restoration

P4 DAM backups only back up metadata stored in P4 DAM. Make sure to also back up the P4 Server so you do not lose data about changelist history, file content, and other data. See Backup and recovery in the P4 Server Administration Documentation.

Backups are available as part of the Perforce TeamHub packages. Backups are activated with configuration flags. The nature of backups changes from one P4 DAM component to another:

Component Method Schedule Description
Assets Archival Daily at 00:00 Attachments, Avatars, Logs, Configuration files
MongoDB Archival Daily at 00:00 Mongo dumps

Backup and restore order

You must configure the backup and restore to happen in this order:

  1. Backup P4 DAM using TeamHub backup

  2. Backup P4 Server

  3. Restore P4 Server

  4. Restore P4 DAM

Preparation

P4 DAM stores backups at /var/opt/hth/backups. For production deployments, the recommendation is to mount a reliable external storage that has enough space to accommodate at least 1.5 times the P4 DAM data set (/var/opt/hth/shared).

Enable backups

To enable backups, activate them by setting the following configuration flags:

Standard

  1. Merge the following configuration to /var/opt/hth/shared/hth.json and make sure you add the backup settings under the existing keys if they already exist in the configuration.

    {
      "backend": {
        "backups": true
      },
      "mongodb": {
        "backups": true
      }
    }
    
  2. Apply the changes by reconfiguring TeamHub:

  3. sudo hth-ctl reconfigure

Enterprise

In Enterprise deployment, the P4 DAM services are distributed across the server roles. To enable backups, activate the backup flags in /var/opt/hth/shared/hth.json on the appropriate servers. Make sure you add the backup settings under the existing keys if they already exist in the configuration.

Perforce TeamHub DB

{
  "mongodb": {
    "backups": true
  }
}

By default, mailing is not configured for the DB node. To get notifications if failures occur during DB backups, you need to add the following:

  1. Configure the postfix section of hth.json to be identical with the one on your web node.
  2. Add the email that will receive the notifications to the app section of hth.json:

    {
      "app": {
        "email": "support@acme.com"
    
      }
    }
    

P4 DAM Web

{
  "backend": {
    "backups": true
  }
}

Apply the changes by reconfiguring P4 DAM on each server:

sudo hth-ctl reconfigure

Configure how many backups to keep before oldest backup gets removed

You can configure archival mode backups to prune old backups. The configuration below keeps the 30 latest backup archives and deletes the oldest when a new backup occurs.

{
  "backups": {
    "keep": 30
  }
}

Restore backups

Because P4 DAM backups are modular, when it comes to restoring the system from a backup, it is important to consider the following:

  • Follow the correct order of restoring the backup components:

    1. P4 Server
    2. Assets
    3. MongoDB Database
  • Because backups for P4 DAM components are taken daily, it is important to restore all components from the same day. Doing otherwise will lead to data inconsistency.

Stop services

Before starting the restoration process, it is a good idea to stop all the P4 DAM services:

sudo hth-ctl stop

Restore assets

  1. SSH into one of the P4 DAM Web servers (or the Combo) and switch to the hth user.
  2. Copy the backend_backup.tar from backup storage, which is located at /var/opt/hth/backups/backend_backup/<date>/.
  3. Extract the archives and restore:

    sudo su - hth
    tar xvf backend_backup.tar
    cd backend_backup/archives; ls *.tar.gz | xargs -i tar xvf {} -C /
    

Restore MongoDB databases

  1. SSH into the TeamHub DB server (or the Combo) and switch to the hth user.
  2. Copy mongodb_backup.tar from the backup storage /var/opt/hth/backups/mongodb_backup/<date>/.
  3. Start MongoDB, extract the archives, and restore:

    sudo su - hth
    sudo hth-ctl start mongodb
    tar xvf mongodb_backup.tar; cd mongodb_backup/databases/; tar xvf MongoDB.tar.bz2
    

    For Standard deployment without MongoDB authentication, use the following command to restore the database:

    mongorestore --port 4002 --drop MongoDB/

    For Enterprise or Standard deployments with MongoDB authentication, use administrator credentials to restore the database:

    mongorestore --port 4002 -u <administrator-username> -p <administrator-password> --drop MongoDB/

Start P4 DAM

Start back all P4 DAM services:

sudo hth-ctl start

Reconfigure P4 DAM

If there have been changes to the hth.json restored from backups, apply those changes by running the reconfigure command:

sudo hth-ctl reconfigure