Spatior got a lot of good things right, here's what a few more years of tar has yielded:
First of all: make sure you have GNU tar (like the one in Linux).
For example, HP-UX tar cannot handle files over 2GB and does not support in-line compression.
GNU tar, however is available for HP-UX and can do anything you can think of (yes, even multi-stage incremental backups)
1) yes, use "tar -ztf tarfile" to see what files are in the archive and "tar -zxf tarfile file1 file2" to restore singular files.
I have made backups that fill up 400GB hardware-compressed tapes. Even then, you can instruct tar to ask for the next tape and continue the backup (it's awesome like that)
You can also use the -T option to give it a file with a list of files to restore.
tar -ztf my_mackup.tar.gz > contents.lst
vi contents.lst
tar -T contents.lst -zxf my_backup.tar.gz
2) when creating the backup, you can try piping to dd and writing to /dev/null to check the resulting filesize.
example: "tar -zcf - /huge_filesystem |dd bs=1M of=/dev/zero"
This will report your backup size in megabytes.
A similar trick can be user to check the size of a restore:
"tar -zxOf /mnt/usbdisk/my_backup.tar my/restored/directory |dd bs=1M of=/dev/zero"
Compression rates are highly dependent on the compression type and data to be compressed. database tables compress more than JPEG images do. Likewise, "compress" doesn't compress very well, "gzip" is OK and and "bzip2" is better but higher compression also meand higher CPU usage and slower backups.
compress, gzip and bzip2 are options -Z, -z and -j, respectively in GNU tar.
3) According to the documentation, modern GNU tar can handle unlimited filesizes:
http://www.gnu.org/software/tar/manu...n/Formats.html
4) indeed, nice works rather well (especially if you want to hog the cpu with compression)
5) same answer: just prepend "nice" =)
To make the backup complete, I would check the exit status ($?) and report it, along with the backup contents, via mail.
Here's what I use at home:
#!/bin/bash
PID=$$
SKIP=0
if [ "${SKIP}" -eq "1" ]
then
echo Backup SKIPPED because of config variable | mail -s "Backup SKIPPED" root
exit 1
fi
touch /var/tmp/${PID} /var/tmp/${PID}.err
/root/disk-backup.sh >/var/tmp/${PID} 2>/var/tmp/${PID}.err
EXITSTATUS=$?
if [ "${EXITSTATUS}" -eq "0" ]
then
cat /var/tmp/${PID} | mail -s "Backup SUCCESS" root
rm /var/tmp/${PID} /var/tmp/${PID}.err
else
cat /var/tmp/${PID} /var/tmp/${PID}.err |mail -s "Backup ERRORS" root
fi
exit ${EXITSTATUS}