Skip to content

Backups

a-a-hofmann edited this page Oct 23, 2019 · 7 revisions

MongoDB

Create backup

# ./scripts/backup-mongo.sh <backup filename prefix> <folder where to place backups>

./scripts/backup-mongo.sh mongo backups/

To restore from backup

# ./scripts/restore-mongo-backups.sh <Relative path to backup file>. 
# Expected structure inside backup folder mongo-xxx/access/
# info1-mngr@inforecover-exercises:~/backup/mongodump/access$ ls -l
# total 252256
# -rw-r--r-- 1 ... ... 258302988 Oct 23 18:28 studentSubmissions.bson
# -rw-r--r-- 1 ... ...       173 Oct 23 18:28 studentSubmissions.metadata.json

./scripts/restore-mongo-backups.sh backups/mongo-2019-09-27_21_16_04/

Postgres

To create a backup

# ./scripts/backup-postgres.sh <backup filename prefix> <folder where to place backups>

./scripts/backup-postgres.sh dump backups/

To restore:

  1. Stop postgres and keycloak
docker-compose stop keycloak && docker-compose stop postgres
  1. Remove any db files
rm -rf volumes/postgres/data/db/*

If no root access!

2a. Remove any db files

docker-compose exec postgres bash
rm -rf /var/lib/postgresql/data/*

# Exit container ctrl+d
docker-compose restart postgres
  1. Restart postgres
docker-compose start postgres
  1. Restore from backup
# ./scripts/restore-postgres-backups.sh <Relative path to backup file>

./scripts/restore-postgres-backups.sh backups/dump-2019-09-26_21_22_20.sql
  1. Restart keycloak
docker-compose start keycloak