Backup and restore

Postgres

Dump database

docker exec -ti postgres pg_dump -Fc -U postgres elm-integration -f /tmp/gamebench-postgres-backup-$(date +"%Y-%m-%d_%H-%M-%S").dump

Restore database from backup

Please note the database will be dropped before being restored, ensure the backup is taken first and the file was successfully written.

docker exec -ti postgres psql -U postgres -c 'DROP DATABASE "elm-integration"'
docker exec -t postgres pg_restore -C -d postgres -U postgres /tmp/<backup postgres filename>

Data

If you’ve bind-mounted your data directory, you can skip this step and use the bind mount destination.

Find volume mountpoint

docker volume inspect -f '{{.Mountpoint}}' $(docker volume ls | grep filedata | awk '{ print $2 }')

Archive data

sudo tar -C <volume mountpoint> -czf gamebench-data-backup-$(date +"%Y-%m-%d_%H-%M-%S").tar.gz .

Restore data

sudo tar -C <volume mountpoint> -xzf <data backup filename>
Last updated on