BRIX On-Premises > BRIX On-Premises Enterprise / Backup and recover databases

Backup and recover databases

Elma365-Backupper is a utility that allows for backup of BRIX application data.

 

Backup of BRIX should include:

  • PostgreSQL. The database stores the main system data: users, application items, application settings, workspaces, processes, pages, widgets, tasks, events, and other configuration settings.
  • MongoDB. This database contains unstructured system settings, chat data, and activity streams.
  • S3 Object Storage. The object storage holds uploaded and created files in BRIX of any type and size, such as documents, photographs, audio, and video files.

Начало внимание

When creating a backup copy, the BRIX services are stopped, and the application itself becomes unavailable.

Конец внимание

 

The process of database backup and recovery consists of four steps:

  1. Install elma365-Backupper.
  2. Configure elma365-Backupper.
  3. Database backup.
  4. Database recovery.

Step 1: Install elma365-Backupper

  1. Install the packages:

sudo apt install -y apt-transport-https ca-certificates curl

  1. Import the keys:

sudo curl -fsSL https://repo.elma365.tech/deb/elma365-keyring.gpg | gpg --dearmor > /etc/apt/trusted.gpg.d/elma365-keyring.gpg

  1. Add the BRIX repository:

echo "deb [arch=amd64] https://repo.elma365.tech/deb $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/elma365.list
sudo apt update

  1. Install elma365-Backupper:

sudo apt install elma365-backupper

Installation for Red Hat-like operating systems

Step 2: Configure elma365-Backupper

  1. Open configuration file /opt/elma365/backupper/etc/config:

nano /opt/elma365/backupper/etc/config

  1. In the file fill out the parameters:
  • KUBECONFIG — the path to the kubeconfig file, used for selecting the Kubernetes cluster and connecting to the Kubernetes API server. If not specified, $HOME/.kube/config is used by default.
  • BACKUP_DST — the directory where the backup will be saved. Available options are:
    • filesystem — backup is saved to the local file system at the path specified in BACKUP_PATH.
    • s3 — backup is saved to an S3 storage, using settings specified in parameters S3_BUCKET_NAME, S3_HOST, S3_PORTS3_ROOT_USER, S3_ROOT_PASSWORD, S3_SSL_ENABLED.
  • K8S_NS_DBS — the namespace where the BRIX application is installed.
  • K8S_NS_APP — the namespace where the built-in databases are installed, set up in the Kubernetes cluster; see Prepare embedded databases.
    Ensure ports 7000, 7001, 7002 are available for port forwarding to access databases in the Kubernetes cluster. If necessary, ports can be overridden in S3_SRC_PORT, PG_SRC_PORT, MONGO_SRC_PORT.
  • BACKUP_LIFE — the period in days for storing backup copies. Copies older than this value will be deleted during the next backup.
  • TMP_DIR — the directory for storing temporary backups. There should be enough space for one backup. The backup is assembled in this directory before being moved to the storage location specified in BACKUP_DST.

Example of a configured file

Step 3: Database backup

Perform a backup of the BRIX application databases:

elma365-backupper backup <<db-type>>

where <<db-type>> is the name of the database for which you want to perform the backup. The possible values for the argument are:

  • mongo  for MongoDB.
  • postgres for PostgreSQL.
  • s3 for S3 storage.
  • all for all databases (MongoDB, PostgreSQL, S3).

Additional backup command keys

Step 4: Database recovery

You can restore databases from the latest or a specific version of the backup.

Начало внимание

Restoration from a backup should be carried out in empty databases and S3 storage.

Before restoring data from a backup, clear the databases and S3 storage or use the --cleanup-databases key.

Конец внимание

For more details on how to prepare databases for restoration, refer to the following articles: PostgreSQL and MongoDB.

Restoration from the latest backup

Execute the command:

elma365-backupper restore <<db-type>>

where <<db-type>> is the name of the database for which you need to retrieve the list of backups. The argument values can be:

  • mongo for MongoDB;
  • postgres for PostgreSQL;
  • s3 for S3 storage;
  • all for all databases (MongoDB, PostgreSQL, S3).

With this command, you can restore databases to the latest backup found in the storage. 

Restoration from a specific backup

  1. Get the list of backups from the storage:

elma365-backupper backup-list <<db-type>>

where <<db-type>>  is the name of the database for which you need to retrieve the list of backups. The argument values can be:

  • mongo for MongoDB;
  • postgres for PostgreSQL;
  • s3 for S3 storage;
  • all for all databases (MongoDB, PostgreSQL, S3).

Additional keys for the backup-list command

Depending on the backup storage method indicated in the BACKUP_DST parameter, the backup-list command will return:

  • For s3: names of directories with dumps in S3 storage.
  • For filesystem: absolute paths to directories with dumps in the file system.
  1. Execute database restoration from a specific backup:

elma365-backupper restore <<db-type>> --backup-path /path/to/backup

The backup for database restoration is taken from the storage specified in the BACKUP_DST parameter:

  • If S3 storage is indicated:

elma365-backupper restore <<db-type>> --backup-path ELMA365_YYYY.MM.DD-HH.MI.SS

  • If a local directory is indicated:

elma365-backupper restore <<db-type>> --backup-path /opt/elma365/backupper/backup/ELMA365_YYYY.MM.DD-HH.MI.SS/

Additional keys for the restore command