Skip to content

Instantly share code, notes, and snippets.

@zinderud
Created March 12, 2021 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zinderud/15b533ac391d71e1d8d78f77fec72ec6 to your computer and use it in GitHub Desktop.
Save zinderud/15b533ac391d71e1d8d78f77fec72ec6 to your computer and use it in GitHub Desktop.
Docker Backup
inceleme listesi
https://github.com/camptocamp/bivac
docker run -d --name bivac -v /var/run/docker.sock:/var/run/docker.sock:ro \
-e AWS_ACCESS_KEY_ID=XXXX \
-e AWS_SECRET_ACCESS_KEY=XXXXXX \
-e BIVAC_TARGET_URL=s3:my-bucket \
-e RESTIC_PASSWORD=foo \
-e BIVAC_SERVER_PSK=toto \
-e BIVAC_AGENT_IMAGE=camptocamp/bivac:stable \
-p 8182:8182 \
camptocamp/bivac:stable manager
You can easily deploy Bivac with a simple docker-compose.yml:
version: '2'
services:
bivac:
image: camptocamp/bivac:stable
command: manager
ports:
- "8182:8182"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
environment:
AWS_ACCESS_KEY_ID: XXXX
AWS_SECRET_ACCESS_KEY: XXXXXX
RESTIC_PASSWORD: foo
BIVAC_TARGET_URL: s3:my-bucket
BIVAC_SERVER_PSK: toto
BIVAC_AGENT_IMAGE: camptocamp/bivac:stable
@zinderud
Copy link
Author

Backup:

docker exec -t -u postgres your-db-container pg_dumpall -c > dump_date +%d-%m-%Y"_"%H_%M_%S.sql

Restore:
cat your_dump.sql | docker exec -i your-db-container psql -Upostgres

@zinderud
Copy link
Author

docker uzerindeki psql volumleri belirli zaman aralıklarında yedekleme işlemi

https://github.com/kartoza/docker-pg-backup

@zinderud
Copy link
Author

Deleting all the volumes

Once all the containers are deleted, you can delete all the Docker volumes on your computer using the following command

docker volume prune

If you don't want to delete all the Docker volumes on your computer, you can search for a specific one and deleting it

docker volume ls
docker volume rm <name_of_volume>

@zinderud
Copy link
Author

https://blog.koley.in/2019/backup-and-restore-postgresql-database-running-on-docker

To backup, we use the pg_dump tool:

docker exec <postgres_container_name> pg_dump -U postgres <database_name> > backup.sql

This would create a text file named backup.sql containing all the data and schema of your database. You can then import this data back into postgres using the psql tool:

docker exec -i <postgres_container_name> psql -U postgres -d <database_name> < backup.sql

The -i flag is of particular importance here because the psql tool needs to be run interactively for it to be able to read from the backup.sql file.

Note: The above commands assume that you have postgres as the default user for the database. This is indeed the case for the standard postgres docker image.

@zinderud
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment