I have a lot of data in /var/www/html
.
It's more than 2GB.
Now I have the possibility to host the website on the host (nginx
is using /var/www/html) or I can use docker.
For the user of docker I am copying the content of /var/www/html
to another folder (src/
) and I mount src/
inside my container:
Steps:
stop nginx
copy files /var/www/html --> xxx/src/
start docker
The copy takes some minutes so there is some downtime. Is it a bad idea to do the following:
copy files /var/www/html --> xxx/src/ (while nginx is running)
stop nginx
start docker
Can there be an issue?
It entirely depends on your use-case. Let me try to describe the possible scenarios and corresponding solutions.
If the data doesn't change fast or doesn't grow in size during the time it gets copied to another location, then there is no need to worry about the state (running / stopped) of the web server. Just copy the data and then switch the web server (from Nginx to Apache / Docker, for example).
If the data only grows in size (rather than change of content), then you may use rsync a couple of times before switching the web server. For the first time, rsync would copy the entire data (2GB or whatever). When rsync runs the second time, it'd only copy the new data (that was added when rsync was run the first time). In this situation, you'd want to stop the web server when rsync was run the second time. In this way, you'd minimize the downtime. It takes very less time to copy the newly added data than copying the entire data.
If the data changes (rather than grow in size), then you should definitely stop, copy and then start the web server.
If the data changes and also grows in size, then you should certainly stop, copy and then start the server too.
Whatever your scenario is, I highly recommend using rsync to reduce the downtime by copying most of the existing data to the new location.
I hope that helps.