Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Let's say I do this tar cfzp home.tar.gz /home (takes a while) and a file changes during compression and tar fails, I get "file changed as we read it" and tar stops. I assume home.tar.gz is now incomplete, or was that just the "notice" and not really an error?

Is there some kind of "force" option to make tar finish its work and not abort on errors?

Edit/update: I found "--ignore-failed-read do not exit with nonzero on unreadable files" and at least I think it's working. But need to be careful with the order of the parameters because you can end up with a tar file called "--ignore-failed-read"

Do I need to ignore anything else?

Update: Without "--ignore-failed-read" tar will keep going if a file has been removed "File removed before we read it". However, I think it might be aborting on the "file changed as we read it" error but I don't really know. Hard to compare the archive to the "original" as I have cache files that come and go, etc.

Update: Upon closer observation "file changed as we read it" is more like a notice, it appears tar will keep going if files change while tar is doing its business. But I'll leave the answer open, maybe someone more experienced can add more insight.

share|improve this question
    
What is the error message that you get when tar fails ? –  Iain Dec 11 '13 at 19:16
    
Which time? When compression fails or when the --ignore-failed-read fails? –  PJ Brunet Dec 11 '13 at 19:20
    
All are relevant surely. –  Iain Dec 11 '13 at 19:20
    
what do you get in stderror when doing "tar cfzp home.tar.gz --ignore-failed-read /home" ? –  Danila Ladner Dec 11 '13 at 19:24
    
I didn't save the error, it was something like "file changed during compression...aborting." Actually "tar cfzp home.tar.gz --ignore-failed-read /home" seems to be working now so I'm not sure what the (file not found) error was from :-/ I edited the question to clear up my confusion with --ignore-failed-read –  PJ Brunet Dec 11 '13 at 19:25

1 Answer 1

Your assumption is correct, "File changed as we read it" is a notice, usually related to files in use (i.e. written to during the creation process) while tar is creating the archive. If consistency is vital, you're better off rsyncing the contents elsewhere i.e.

rsync -avz /my/home/ /somebackupdir/my/home/  # initial sync, followed by 
rsync -avz /my/home/ /somebackupdir/my/home/  # any subsequent sync, repeated
                                              # as often as you feel necessary

This gives you the benefit of having a backup location that will only need to update the diffs before creating the tarball.

share|improve this answer
    
If you had just said "Yes, it's a notice" I might have accepted it. But you gave me two answers, which is kinda confusing. I appreciate the rsync recommendation but it's a question about tar, so I dunno. Ideally I'd like to see an answer like "tar won't ever abort unless..." –  PJ Brunet Dec 15 '13 at 4:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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