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.

2 Answers 2

0

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

1
  • That answer is very vague and almost not usable. Could you please expand it so that future readers can profit from it?
    – slhck
    Commented Jul 16, 2019 at 13:50
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.

5
  • 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. Commented Jul 16, 2019 at 11:51
  • 1
    Just 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
    Commented Jul 16, 2019 at 12:03
  • @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
    Commented Jul 16, 2019 at 13:37
  • @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. Commented Jul 16, 2019 at 13:50
  • 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
    Commented Jul 16, 2019 at 13:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .