docker-library / ghost

Docker Official Image packaging for Ghost
https://hub.docker.com/_/ghost
MIT License
745 stars 314 forks source link

how to backup and restore ghost cms docker easyly #374

Closed View-my-Git-Lab-krafi closed 1 year ago

View-my-Git-Lab-krafi commented 1 year ago

I tried so hard to understand how docker work and creating backup and restore. already tried tuns of stuff but non of them worked. i waste today completely finding solution. but i failed.

technique one :

sudo docker commit efef1f15b461 mycontainer_backup && docker save mycontainer_backup -o mycontainer_backup.tar

to restore docker load -i mycontainer_backup.tar docker run -it --name mycontainer mycontainer_backup issue is /var/lib/ghost/content folder get missing and output says my theme got missing if i get inside docker and fix that after running that command again theme get missing....

sudo docker export efef1f15b461 | openssl enc -aes-256-cbc -pbkdf2 -pass pass:hack -out out/"asd.tar.enc" -v also i tried this encryption script ..

simple backup and restore.

yosifkit commented 1 year ago

Assuming that you are using a sql database, then you'd need to backup that along with the content directory/volume that you are mounting: -v /path/to/ghost/blog:/var/lib/ghost/content. Nothing else in the container is stateful unless you are in development mode using a SQLite file, so that should also be saved (-e database__connection__filename='/var/lib/ghost/content/data/ghost.db' to control where it goes, like in the mounted directory).

The reason docker commit doesn't work is that /var/lib/ghost/content is defined as a docker volume which means it is not included in the new image or in a docker export.