This will include the information on backup and restoration of BrowserStack Code Quality data for docker setup. Below are the 2 scenarios

  • backup & restore on same machine i.e on same docker
  • backup & restore from one machine to another machine i.e from one docker to another docker on another machine

Follow the steps based on source and destination platforms.

Docker : backup & restore on same machine:

Suppose you have used below command for execution of docker

docker  run -m 10GB -d  -p 3000:3000 --name CODEQUALITYBACKUP  -e gamma_ui_public_host=http://3.72.41.7:3000 -e RISK_XMX=-Xmx1024m -e ACCEPT_EULA=Y -e ANALYSER_XMX=-Xmx3072m -v /Users/saurabh/dockervolumes/data:/opt/gamma_data -v /Users/saurabh/dockervolumes/db:/var/lib/postgresql -v /Users/saurabh/dockervolumes/logs:/opt/gamma/logs embold/gamma:1.9.18.0

NOTE : In below document above volume mapping host paths are used for reference only. Make sure you use your volume paths used in your docker command.

Backup phase :

  • First login to Code Quality with your credentials and enable backup from settings and schedule it as per your requirements. PFA Below image for reference.
  • Once schedule make sure backup_path shown in above image is mapped to host_path via docker volumes . By default it is mapped to /opt/gamma_data/ inside the docker
  • Inside host at path /Users/saurabh/dockervolumes/data(As per our reference docker command at start of document) it will generate .sql files PFA snapshot for reference. There will be two .sql files created in the format as below
    gamma_database_backup_DDMMYYYY_HHMMSS.sql
    corona_database_backup_DDMMYYYY_HHMMSS.sql.
  • There can be multiple sql generated due to backup execution at different intervals as per schedule interval, but make sure we should use both sql with same date and time for restoration.
    For e.g : gamma_database_backup_07092023_102900.sql and corona_database_backup_07092023_102900.sql
  • For reference see below image.
  • Inside docker, By default backup path is /opt/gamma_data which hold all the sql with data.
  • Now create a directory for DB sql on docker host machine.
    For eg: – /home/user/Documents/dbrestore
  • Move only 2 sql file i.e gamma and corona sql from the backup_path to /home/user/Documents/dbrestore. Make sure we should use both sql with same date and time for restoration
    For e.g : gamma_database_backup_07092023_102900.sql and corona_database_backup_07092023_102900.sql
  • Get docker container ID and navigate inside it through command
    docker exec -it <container-id> bash
    Create “dbrestore” folder inside /home directory and exit the container.
  • Execute the below commands from host machine to move data from /home/user/Documents/dbrestore to /home/dbrestore folder inside the docker:
docker cp /home/user/Documents/dbrestore/gamma_database_backup_07092023_102900.sql CODEQUALITYBACKUP:/home/dbrestore

docker cp /home/user/Documents/dbrestore/corona_database_backup_07092023_102900.sql CODEQUALITYBACKUP:/home/dbrestore

For reference see below image.

Restore phase :

  • Get inside the container and run below command
    pm2 stop app
  • To Restore execute shell script located at /opt/gamma//gamma_ui/dbscripts/scripts/backup_restore.sh. It will prompt you for inputs see below image for reference and provide same except the name of your sql files.
  • Once DB restore script is executed , Run command pm2 start app
  • Exit the docker.
  • You have successfully restored your database to the backup point of generated sql.

Docker : backup & restore from one machine to another machine.

Backup phase :

  • First login to Code Quality with your credentials and enable backup from settings and schedule it as per your requirements. PFA Below image for reference.
  • Once schedule make sure custom backup_path is mapped to host_path via docker volumes . By default it is mapped to /opt/gamma_data/ inside the docker
  • Inside host at path /Users/saurabh/dockervolumes/data (As per our reference docker command at start of document) it will generate .sql files PFA snapshot for reference. There will be two sql files created in the format as below
    gamma_database_backup_DDMMYYYY_HHMMSS.sql
    corona_database_backup_DDMMYYYY_HHMMSS.sql.
  • There can be multiple sql generated due to backup execution at different intervals as per schedule interval, but make sure we should use both sql with same date and time for restoration.
    For e.g : gamma_database_backup_07092023_102900.sql and corona_database_backup_07092023_102900.sql
  • For reference see below image
  • Copy these sql files to new host machine at place : /home/backup_sql
  • Copy your entire gamma_data volume on host machine, in our case as per our docker command i.e /Users/saurabh/dockervolumes/data (As per our reference docker command at start of document) to the new host machine and store it at location : /home/backup_data.

Restore Phase :

  • On new machine use /home/backup_data to map to /opt/gamma_data, execute below docker command
docker  run -m 10GB -d  -p 3000:3000 --name CODEQUALITYRESTORE  -e gamma_ui_public_host=http://3.72.41.7:3000 -e RISK_XMX=-Xmx1024m -e ACCEPT_EULA=Y -e ANALYSER_XMX=-Xmx3072m -v /home/backup_data:/opt/gamma_data -v /newpath/db:/var/lib/postgresql -v /newpath/logs:/opt/gamma/logs embold/gamma:1.9.18.0
  • After activation, get inside the container and run below command
    pm2 stop app
  • Now create a directory for DB sql on docker host machine.
    For eg: – /home/user/Documents/dbrestore
  • Move only 2 sql file i.e gamma and corona sql from /home/backup_sql to /home/user/Documents/dbrestore. Make sure we should use both sql with same date and time for restoration
    For e.g : gamma_database_backup_07092023_102900.sql and corona_database_backup_07092023_102900.sql
  • Get docker container ID and navigate inside it through command
    docker exec -it <container-id> bash
    Create “dbrestore” folder inside /home directory and exit the container.
  • Execute the below commands from host machine to move data from /home/user/Documents/dbrestoreto /home/dbrestore folder inside the docker:
docker cp /home/user/Documents/dbrestore/gamma_database_backup_07092023_102900.sql CODEQUALITYRESTORE:/home/dbrestore

docker cp /home/user/Documents/dbrestore/corona_database_backup_07092023_102900.sql CODEQUALITYRESTORE:/home/dbrestore

For reference see below image.

  • To Restore execute shell script located at /opt/gamma//gamma_ui/dbscripts/scripts/backup_restore.sh. It will prompt you for inputs see below image for reference and provide same except the name of your sql files.
  • Once DB restore script is executed , Run command pm2 start app
  • Exit the docker.
  • You have successfully restored your database to the backup point of generated sql.