Sometimes you may with to add files to an existing backup; if you issue a command like:
tar -cvf /dev/st0 backupfiles
…and the tape is not already set to the end of the previous archive you will over-write any data from the position on the tape. Use the “eom” command to move the tape to the end of the alread-recorded files like so:
mt -f /dev/[path-to-tape] eom
mt -f /dev/st0 eom
Now you can use tar to add a file to the tape without over-writing the existing data.
If you have compressible data you may save space on you tapes by using compression; this comes at a cost of CPU cycles to do the compressing, which can often be a worthwhile tradeoff for a long-term backup. To do this is quite simple – add in the -z switch to your tar command.
tar -cvzf /dev/[tape-device] [folder or files to back up]
tar -cvzf /dev/st0 /opt/movies
For some file types – e.g. movies, mp3s, compressed picture files and the like you probably won’t see a great deal of space saved – though if it enough to save you from using two tapes instead of one, it may be worth it even so. Text and other file types may compress more easily and you may see more of a savings – it will vary greatly depending on your dataset. Try it and see!
Sometimes you may see people using the -j switch instead – this uses the bzip2 algorithm rather than the gzip algorithm (the -z switch). You will probably find that gzip is slightly better supported and bzip2 sometimes provides slightly better compression but takes longer. If you are chasing better compression it may be worth replacing the z switch with j to see if it helps.
To put files onto a tape, run the following:
tar -cvf /dev/[path to tape] [file or directory] [file or directory] [file or directory]
An example would be:
tar -cvf /dev/st0 /home/bob
This will back up the user bob’s home directory to the tape, here located at /dev/st0 (a typical location – note the zero, not the letter o).
If you want to use compression in your backup, use the z flag in addition to the other tar flags, such as:
tar -cvfz /dev/st0 /home/bob