How to backup your On-Premise Docker Database

Prev Next

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

  1. 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
  2. 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

  3. 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