3

Is it safe to create a tarball of a directory while the files in the directory are being used (read+write)?

I want to create a backup of a 20GB directory without having to shut down my application server.

I don't mind if the files are changed while the tar is being created, as long as every file is present in the archive, I'm fine with it.

6

It depends. When you're making tarbal (or rsync copy) of changing data, files will be copied in state when copy of that one file started. And that is a trap. If you will have ie. 100 files in directory, all those files will be changing during backup and backup of one file will takes 1s, last copied file will be for 99s newer than first one. This can lead to useless backup if you need all data presenting same time window (ie. you cannot backup database this way).

1

While what Ondra Sniper Flidr writes is true, tar has the habit of refusing to work if the directory changes after it starts archiving. So no, it does not work right even in the scenarios where it should be safe.

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.