How to backup your On-Premise Docker Database
- 20 Feb 2024
- 1 Minute to read
- Print
- DarkLight
- PDF
How to backup your On-Premise Docker Database
- Updated on 20 Feb 2024
- 1 Minute to read
- Print
- DarkLight
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
Introduction
Purpose
To ensure the safety of your data it is recommended to make backups from time to time.
When you have your on-premise instance you can backup the database using the following steps:
Procedure
Backup the database when the container is running using the following command, which saves a backup in the file "dump.sql"
docker-compose exec -T -u postgres db pg_dump iv > dump.sql
Backup the database, when the container is stopped. You can do a backup of your data by simply snapshotting the mounted volume under storage/iv
Restore the database in a new empty database:
# Start database image
docker-compose up -d db
# Restore previous backup into newly created database. Replace "iv" with your ${POSTGRES_DB}!
docker- compose exec -T -u postgres db psql -x iv < ./dump.sql
# Optionally now remove the unneeded backup file
rm ./dump.sql
#Start the server:
docker-compose up -d iv
Was this article helpful?