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?

1 Answer 1

6

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.

3
  • Thanks! Could find this info by googling, hopefully it helps someone else too.,
    – Ucinorn
    Commented Jul 21, 2016 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
    Commented Jul 21, 2016 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. Commented Jul 21, 2016 at 2:38

You must log in to answer this question.

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