Splitting a GNU tar archive across multiple files

Create tar archive files of no larger than 31 GBytes:

tar -cv -M -L 32505856 -f backup.tar ~jfroebe
  • -c create tar archive
  • -v verbose output
  • -M enable multi-volume handling (multple tapes or files)
  • -L size of file in kilobytes
  • -f name of first tar archive file
  • ~jfroebe directory that I wish to backup
  • when 31 GBytes is reached, it will ask you to insert the next file
  • n backup.tar2 <ENTER>Y<ENTER>
  • n next ‘word’ is the name of the new file (or tape drive)
  • Y<ENTER> tar will ask you to change the file ‘backup.tar2’ and confirm tar is to proceed. Since it is a new file, go right ahead and tell it to proceed

Restore the contents of a multi-volume tar file:

tar -xv -M -f backup.tar -f backup.tar2
  • tar recognizes multiple files in the restore with the only criteria being that they are in order. Meaning, tar won’t be able to restore all of the data if you do:
tar -xv -M -f backup.tar2 -f backup.tar

You can also do this with compression:

  • Example:
  • tar -cv -z -M -L 32505856 -f backup.tar.gz ~jfroebe
    tar -xv -z -M -f backup.tar.gz -f backup.tar2.gz
  • There are three methods of compressing with the GNU tar, each requires that the programs are installed
    • bzip2
    • -j parameter
    • bzip2 software package (bzip2)
  • zlib
    • -z parameter
    • gzip software package (gzip/gunzip)
  • compress
    • -Z parameter
    • ncompress software package (compress/uncompress)
  • While bzip2 typically provides the best compression, gzip is far more common in corporate environments.
  • ‘compress’ provides the worst compression and is the slowest but is guaranteed to be on all commercial unix boxes
  • GNU Tar for windows can be obtained GNU Tar and work just the same as the unix versions. Using tar is a great way for tranferring a large file or a whole bunch of files to/from windows while not having to worry about changes in the file names that can sometimes happen with filenames having unicode and/or extended characters.

    Share Button

    Leave a Reply

    Your email address will not be published. Required fields are marked *