2

I have a large (>10GB) folder full of images on a live webserver that I need to back up and transfer.

I'm worried that if I tar the folder, the files will be blocked for reading by the webserver, which is hitting the files many times per second.

Does the tar command in linux block the files it's working on from being read?

5

In a word, "no" :-)

Linux tar will not stop any other process from reading the files while it is running.

If you are concerned about writing the tar doesn't block that either, but if a file changes while tar is reading it then you'll get a warning message; if the directory structure changes while tar is in the middle of it then you might see some oddities in the results (missing files, duplicated files on both paths, etc).

So reads are perfectly safe, writes may require a little more care.

  • Thanks! Could find this info by googling, hopefully it helps someone else too., – Ucinorn Jul 21 '16 at 0:27
  • 1
    The entire lock for writing is a confusion coming from MS Windows systems. By default *nix systems will even allow parallel writes to pretty much any file (which results in garbage most of the time, but hey). You need to do explicit flock calls to make file locks. – grochmal Jul 21 '16 at 0:34
  • And keep in mind, if files are being created, modified, or deleted in the middle of tar trying to do its work, you might not like the results. – Edward Falk Jul 21 '16 at 2:38

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.