I have a directory containing a lot of result log files (directory size ~ 4GB), and a set of processes running that keep on writing to these files.
To be able to correctly analyze the results at a later time, I want to copy the whole directory to an archive destination, and I cannot stop the processes.
I want a copy of the directory as it was at a particular point of time. As the size directory is huge (which means it takes about 40 seconds to copy) and some of the files are being written to, a normal
cp -r does NOT give me a snapshot at a particular point in time, rather a snapshot of files spread over some 40 seconds. This is not good enough.
Is there a way to get an exclusive lock on the directory and all its components while copying?