0

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?

3
  • I don't copy the application data inside the container, you can use docker volume or bind mounts to export the data to the container, example docker run --name webserver -v /var/www:/var/www -d httpd – c4f4t0r Aug 23 '17 at 20:36
  • @c4f4t0r yep I know, but the docker is irrelevant here. I want to know it it could cause issues to copy files in /var/www/html where an nginx service is running – DenCowboy Aug 23 '17 at 20:49
  • @DenCowBow I not sure what you mean telling, where nginx is running, but If you copy your files in the nginx doc root, I don't see any problem. – c4f4t0r Aug 24 '17 at 1:00
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.