Backup on the Same Machine

  1. Enable backup in BrowserStack Code Quality settings and schedule it.
  2. Ensure the backup path (/opt/gamma_data) is mapped to a host directory via Docker volumes.
    Example: /Users/saurabh/dockervolumes/data.
  3. After the scheduled backup, .sql files are generated in the format:
    • gamma_database_backup_DDMMYYYY_HHMMSS.sql
    • corona_database_backup_DDMMYYYY_HHMMSS.sql
  4. Select both SQL files with the same timestamp (e.g., 07092023_102900).
  5. Create a directory for the SQL files on the host, e.g., /home/user/Documents/dbrestore.
  6. Move the .sql files to this directory.
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.28.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.

  • 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 on the Same Machine

  • Copy the .sql files into the Docker container:
    docker cp /home/user/Documents/dbrestore/.sql :/home/dbrestore
  • Enter the container:
    docker exec -it bash
  • Stop the application:
    pm2 stop app
  • Execute the restore script
    /opt/gamma/gamma_ui/dbscripts/scripts/backup_restore.sh
  • Start the application
    pm2 start app

Backup & Restore Between Machines (Docker)

Backup phase :

  • Enable and schedule backup as described above.Copy the .sql files and the gamma_data directory from the source to the new host:
    SQL files: /home/backup_sql.
    Data directory: /home/backup_data.
  • On the new host, map the paths in Docker
  • docker run -m 10GB -d -p 3000:3000 –name CODEQUALITYRESTORE \
  • -v /home/backup_data:/opt/gamma_data \
  • -v /newpath/db:/var/lib/postgresql \
  • -v /newpath/logs:/opt/gamma/logs embold/gamma:1.9.28.0

Restore Phase :

  • Restore the SQL files as described earlier
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.28.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.