How to backup your On-Premise Docker Database
  • 20 Feb 2024
  • 1 Minute to read
  • Dark
    Light
  • PDF

How to backup your On-Premise Docker Database

  • Dark
    Light
  • PDF

Article summary

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


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.