Last active
October 21, 2019 20:10
-
-
Save blohinn/e301fb4d13c75d7db59de747c0fc358f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Бэкап данных (+ создание таблиц) | |
Подразумевается, что бд tatcamps.dev.postgres существует, но таблицы в ней удалены для создания бэкапов | |
docker exec -t tatcamps.prod.postgres pg_dump -U tatcamp --column-inserts tatcamp > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql | |
docker exec -t ulmts.postgres psql -U ulmts ulmts -t -c "drop schema public cascade; create schema public;" | |
cat your_dump.sql | docker exec -i tatcamps.dev.postgres psql -U tatcamp -d tatcamp | |
############################ | |
# # Работает внутри контейнера (без приставки docker exec -t <container_uid>) # # | |
docker exec -t <container_uid> pg_dump -U smartnet -d smartnet -F c > dump_`date +%d-%m-%Y"_"%H-%M`.gz | |
docker exec -t <container_uid> pg_restore -U smartnet -d smartnet <dumpfile>.gz | |
# # Через gzip (запуск за пределами контейнера) # # | |
docker exec -t <container_uid> pg_dump -U smartnet -d smartnet | gzip > dump_`date +%d-%m-%Y"_"%H-%M`.gz | |
gunzip <dumpfile>.gz | |
cat <dumpfile> | docker exec -i <container_uid> psql -U smartnet -d smartnet | |
# Или сразу, без распаковки | |
gzcat <dumpfile>.gz | docker exec -i <container_uid> psql -U smartnet -d smartnet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment