In case of some data loss in the database or the file storage
- Notify the IT partner about the ongoing incident
- Wait until the IT partner responds
- Read the documentation
- Stop all the services [remote VM]
systemctl stop traefiksystemctl stop nginxsystemctl stop php-fpmsystemctl stop redissystemctl stop mariadbsystemctl stop supercronic
- Copy the existing data to the temporary remote location [remote VM]
- Download the binary files [local environment]
- restic
- https://github.com/restic/restic/releases
wget https://github.com/restic/restic/releases/download/v0.16.2/restic_0.16.2_linux_amd64.bz2
- walg
- https://github.com/wal-g/wal-g/releases
wget https://github.com/wal-g/wal-g/releases/download/v2.0.1/wal-g-mysql-ubuntu-20.04-amd64.tar.gz
- restic
- Unpack the binary files [local environment]
bzip2 -d restic_0.16.2_linux_amd64.bz2tar -zxvf wal-g-mysql-ubuntu-20.04-amd64.tar.gz
- Remove archives [local environment]
rm wal-g-mysql-ubuntu-20.04-amd64.tar.gz
- Add execution permissions [local environment]
chmod +x restic_0.16.2_linux_amd64chmod +x wal-g-mysql-ubuntu-20.04-amd64
- Rename the binary files [local environment]
mv wal-g-mysql-ubuntu-20.04-amd64 wal-gmv restic_0.16.2_linux_amd64 restic
- Move the binaries to the directory, which included to the PATH [local environment]
sudo mv wal-g /usr/local/bin/wal-gsudo mv restic /usr/local/bin/restic
- Bootstrap secrets to the shell [local environment] (it is necessary to the replace the %SECRET% with an actual value)
export AWS_ACCESS_KEY_ID=%SECRET%export AWS_SECRET_ACCESS_KEY=%SECRET%export RESTIC_PASSWORD=%SECRET%
- Create necessary directories [local environment]
mkdir -p /tmp/restic/classes /tmp/restic/config /tmp/restic/var /tmp/restic/versions /tmp/restic/recyclebin /tmp/walg/mariadb
- Bootstrap env vars to the shell [local environment]
export RESTIC_REPOSITORY_CLASSES='s3://fra1.digitaloceanspaces.com/bol-bol-pim-application-classes'export RESTIC_RESTORE_DESTINATION_CLASSES='/tmp/restic/classes'export RESTIC_REPOSITORY_CONFIG='s3://fra1.digitaloceanspaces.com/bol-bol-pim-application-config'export RESTIC_RESTORE_DESTINATION_CONFIG='/tmp/restic/config'export RESTIC_REPOSITORY_VAR='s3://fra1.digitaloceanspaces.com/bol-bol-pim-application-var'export RESTIC_RESTORE_DESTINATION_VAR='/tmp/restic/var'export RESTIC_REPOSITORY_VERSIONS='s3://fra1.digitaloceanspaces.com/bol-bol-pim-application-versions'export RESTIC_RESTORE_DESTINATION_VERSIONS='/tmp/restic/versions'export RESTIC_REPOSITORY_RECYCLEBIN='s3://fra1.digitaloceanspaces.com/bol-bol-pim-application-recyclebin'export RESTIC_RESTORE_DESTINATION_RECYCLEBIN='/tmp/restic/recyclebin'export WALG_S3_PREFIX='s3://bol-bol-pim-walg-mysql-storage'export AWS_ENDPOINT='fra1.digitaloceanspaces.com'export AWS_S3_FORCE_PATH_STYLE='true'export WALG_STREAM_RESTORE_COMMAND="mbstream -x -C /tmp/walg/mariadb"
- Restore the file backups one by one [local environment]
restic --repo %REPO% snapshotsrestic --repo %REPO% stats --mode raw-datarestic -r %REPO% restore latest --target %RESTORE_DIR%- example
- classes
restic --repo ${RESTIC_REPOSITORY_CLASSES} snapshotsrestic --repo ${RESTIC_REPOSITORY_CLASSES} stats --mode raw-datarestic -r ${RESTIC_REPOSITORY_CLASSES} restore latest --target ${RESTIC_RESTORE_DESTINATION_CLASSES}
- config
restic --repo ${RESTIC_REPOSITORY_CONFIG} snapshotsrestic --repo ${RESTIC_REPOSITORY_CONFIG} stats --mode raw-datarestic -r ${RESTIC_REPOSITORY_CONFIG} restore latest --target ${RESTIC_RESTORE_DESTINATION_CONFIG}
- var
restic --repo ${RESTIC_REPOSITORY_VAR} snapshotsrestic --repo ${RESTIC_REPOSITORY_VAR} stats --mode raw-datarestic -r ${RESTIC_REPOSITORY_VAR} restore latest --target ${RESTIC_RESTORE_DESTINATION_VAR}
- versions
restic --repo ${RESTIC_REPOSITORY_VERSIONS} snapshotsrestic --repo ${RESTIC_REPOSITORY_VERSIONS} stats --mode raw-datarestic -r ${RESTIC_REPOSITORY_VERSIONS} restore latest --target ${RESTIC_RESTORE_DESTINATION_VERSIONS}
- recyclebin
restic --repo ${RESTIC_REPOSITORY_RECYCLEBIN} snapshotsrestic --repo ${RESTIC_REPOSITORY_RECYCLEBIN} stats --mode raw-datarestic -r ${RESTIC_REPOSITORY_RECYCLEBIN} restore latest --target ${RESTIC_RESTORE_DESTINATION_RECYCLEBIN}
- classes
- Install the mariadb-backup package [local environment]
sudo apt install mariadb-backup
- Restore the database backup [local environment]
mkdir -p /tmp/walg/mariadbwal-g backup-list --pretty --detailwal-g backup-fetch LATEST
- Move the remaining data to the temporary location [remote VM]
- /opt/app/var/classes
- /opt/app/var/config
- /opt/app/public/var
- /opt/app/var/versions
- /opt/app/var/recyclebin
- /var/lib/mysql
- Copy the restored data to the remote VM [remote VM]
- Fix permissions for the restored data [remote VM]
- Start the services [remote VM]
systemctl start traefiksystemctl start nginxsystemctl start php-fpmsystemctl start redissystemctl start mariadbsystemctl start supercronic
- Remove the temporary data [local environment]