![]() Pass a command that tars the contents of the dbdata volume to a backup.tar file inside our /backup directory. Launch a new container and mount the volume from the dbstore container Backup a containerĬreate a new container named dbstore: $ docker run -v /dbdata -name dbstore ubuntu /bin/bash This applies to all kinds of data within a volume, not just postegres. I would like to add the official docker documentation for backups and restores. I then navigated to correct directory (with the project) activated the virtualenv and then ran the accepted answer. I don't know the accuracy of this statement: but I believe I was seeing this as I do not user docker locally, so therefore did not have this file, which it was looking for, using Forth's answer. This can be caused by the file /var/lib/docker/network/files/local-kv.db. This eluded me for a bit before figuring it out- as I was receiving the following docker error. However, in order to get this to work, I had to also go into the virtualenv that the docker container and project were in. (since this was a single db dump and not multiple db's i included the name) The methodology recommended by Forth and edited by Soviut worked for me:Ĭat your_dump.sql | docker exec -i your-db-container psql -U postgres -d dbname I normally use dbeaver to restore- however received a psql dump, so had to figure out a method to restore using the docker container. I had this issue while trying to use a db_dump to restore a db. Now I remove the container used for the db and create another one, with the same name, and try to restore the data inserted before: $ sudo docker run -volumes-from "$DB_CONTAINER_NAME" -rm -v $(pwd):/backup ubuntu tar xvf /backup/backup.tarīut the tables are empty, why is the data not properly restored ? The tar archive is then created: $ sudo docker run -volumes-from "$DB_CONTAINER_NAME" -rm -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /etc/postgresql /var/log/postgresql /var/lib/postgresql Then I connect another container to insert some data manually: docker run -it -rm -link "$DB_CONTAINER_NAME":db "$DB_IMAGE_NAME" sh -c 'exec bash' I create the DB container with this command: docker run -it -name "$DB_CONTAINER_NAME" -d "$DB_IMAGE_NAME" The volumes used by the database image are: VOLUME Īnd the CMD is: CMD I'm trying to backup/restore a PostgreSQL database as is explained on the Docker website, but the data is not restored.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |