0

I am struggeling to get this working. It is no problem for me to set up a Postgres Database with Docker and acess it from other clients with Dbeaver or PGAdmin. My problem is, I am not able to perform an automatic backup of the docker container or volume.

This is my Docker Compose file:

version: '3.8'

services:

  db:
    container_name: imatecTest
    image: postgres
    restart: always
    environment:
      POSTGRES_USER: root
      POSTGRES_PASSWORD: root
      POSTGRES_DB: test
    ports:
      - "5432:5432"
  pgadmin:
    container_name: pgadmin4
    image: dpage/pgadmin4
    restart: always
    environment:
      PGADMIN_DEFAULT_EMAIL: [email protected]
      PGADMIN_DEFAULT_PASSWORD: root
    ports:
      - "5050:80

The only way it "worked" was this: I saved the volume of the docker container locally in my windows directory and did my backup with windows-backup. The problem is I have to shut down my database during the backup otherwise there will be data loss.

Can you give me some advice how to perform an automatic backup of my volume or the whole container with PG_Dump or something else?

1 Answer 1

0

Traditionally you can use pg_dump command to backup your postgres database

pg_dump -U postgres -h localhost -f <BACKUP_FILE> <DATABASE_NAME>

additionally Use a tool like rsync to copy the backup file to the NAS device. You can use a cron job to schedule the backup process to run periodically.

Hope it helps

Sign up to request clarification or add additional context in comments.

2 Comments

Does it work the same way with Docker running on Windows?
these tools should work or you might need to investigate other flavours of rsync

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.