Zip file from Docker volume

0

WordPress is running inside a Docker container. I want to create a separate image which will use cron to automatically create the backup of WordPress files and database. I am confused that what is the best way to access files inside the Docker container in another image using a bash script.

Web

Posted 2019-07-16T08:46:21.460

Reputation: 11

Answers

0

If you want to persist your data you should use volumes. In the simplest case, you "bind-mount" specific locations in the container to locations on the host, so that the container processes write/read to the host file system and the data outlives the container. Once you have done this, backing up the data is done as with any other data.

xenoid

Posted 2019-07-16T08:46:21.460

Reputation: 7 552

I dont want to mount the volume to host, i am creating a script that will zip the file to sftp server and then delete the zip file. – Web – 2019-07-16T11:51:21.520

1Just suggesting the proper way to do things. You may want to do it otherwise but then you may want to think how to get the data back in the container (or in a new container...). – xenoid – 2019-07-16T12:03:27.257

@Web Do yourself a favor and follow this advice. Don't let the WordPress data stay in the container. If the container gets removed or has to be rebuilt, all your data is lost. Also, no other container can access it. The same for the database: provide a separate volume which can be persisted across container runs, and access it from both the WordPress container as well as the one that runs the backups. – slhck – 2019-07-16T13:37:21.033

@slhck the problem is that i copying custom wordpress theme using dockerfile. when i mount the volume on host, theme file is overrided by empty files from the host, thats why i mounted the volume in container instead of host. and i am creating continous backups so that if i had a problem , i can re run from the backup. – Web – 2019-07-16T13:50:58.257

1@Web You have to first mount the volume (e.g. ./data to /var/www/html, and then install the theme. The theme then stays persisted on your host (in ./data). – slhck – 2019-07-16T13:56:14.587

0

Mount the volume from wordpress image to backup image. Create Custom Entrypoint. Write a gist. Zip files and upload.

Web

Posted 2019-07-16T08:46:21.460

Reputation: 11

That answer is very vague and almost not usable. Could you please expand it so that future readers can profit from it? – slhck – 2019-07-16T13:50:19.577