I was making a complete server backup and tried making the tar balls of each directory structure by using the following commands:

nohup tar -cvf - /etc | gzip -9 -c > /opt/Backup_4_Jan/etc.tgz &

nohup tar -cvf - /var/opt | gzip -9 -c > /opt/Backup_4_Jan/var_opt.tgz &

nohup tar -cvf - /usr/opt | gzip -9 -c > /opt/Backup_4_Jan/usr_opt.tgz &

But after transferring these zipped files on the windows machine, extracting it i found some of the tar balls are corrupted. I am sure the transfer was made in the Binary format and i was able to successfully extract /etc.tgz but other two couldn't get extracted due to corruption. I have tried this couple of times and got the same result every time.

So, my question is, am i using the commands in the right way? Or do i have mistake in the above commands, or is there any other way i can make the backups using some other commands?

  • 2
    Test extract of the original files with tar -tf, because they may already be corrupted. If the test extract goes OK, then use some hashing tool like MD5 or SHA to check whether the transferred files and the original gz files are the same. If they aren't the same, then transferring the files corrupted them. If they are the same, then your gzip extraction tool on Windows is broken. – Kyle Jones Jan 16 '13 at 6:40
  • 3
    The -z option in GNU tar will use gzip compression. You don't need the pipeline. – jordanm Jan 16 '13 at 7:20
  • @jordanm you should make your comment an answer – h3rrmiller Jan 16 '13 at 16:49
  • What is corrupted? The compressed file, or the tar archive within? Are you sure the files aren't just truncated (command didn't finish normally, disk full/quota overrun, ..)? – vonbrand Jan 21 '13 at 5:22
  • If it worked for one directory, they are right. – vonbrand Jan 24 '13 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.