tar: Multi-Volume Archives

1 
1 9.6.1 Archives Longer than One Tape or Disk
1 -------------------------------------------
1 
1 To create an archive that is larger than will fit on a single unit of
1 the media, use the '--multi-volume' ('-M') option in conjunction with
1 the '--create' option (⇒create).  A "multi-volume" archive can be
1 manipulated like any other archive (provided the '--multi-volume' option
1 is specified), but is stored on more than one tape or file.
1 
1    When you specify '--multi-volume', 'tar' does not report an error
1 when it comes to the end of an archive volume (when reading), or the end
1 of the media (when writing).  Instead, it prompts you to load a new
1 storage volume.  If the archive is on a magnetic tape, you should change
1 tapes when you see the prompt; if the archive is on a floppy disk, you
1 should change disks; etc.
1 
1 '--multi-volume'
1 '-M'
1      Creates a multi-volume archive, when used in conjunction with
1      '--create' ('-c').  To perform any other operation on a
1      multi-volume archive, specify '--multi-volume' in conjunction with
1      that operation.  For example:
1 
1           $ tar --create --multi-volume --file=/dev/tape FILES
1 
1    The method 'tar' uses to detect end of tape is not perfect, and fails
1 on some operating systems or on some devices.  If 'tar' cannot detect
1 the end of the tape itself, you can use '--tape-length' option to inform
1 it about the capacity of the tape:
1 
1 '--tape-length=SIZE[SUF]'
1 '-L SIZE[SUF]'
1      Set maximum length of a volume.  The SUF, if given, specifies units
11      in which SIZE is expressed, e.g.  '2M' mean 2 megabytes (⇒
      Table 9.1 size-suffixes, for a list of allowed size suffixes).
1      Without SUF, units of 1024 bytes (kilobyte) are assumed.
1 
1      This option selects '--multi-volume' automatically.  For example:
1 
1           $ tar --create --tape-length=41943040 --file=/dev/tape FILES
1 
1      or, which is equivalent:
1 
1           $ tar --create --tape-length=4G --file=/dev/tape FILES
1 
1    When GNU 'tar' comes to the end of a storage media, it asks you to
1 change the volume.  The built-in prompt for POSIX locale is(1):
1 
1      Prepare volume #N for 'ARCHIVE' and hit return:
1 
1 where N is the ordinal number of the volume to be created and ARCHIVE is
1 archive file or device name.
1 
1    When prompting for a new tape, 'tar' accepts any of the following
1 responses:
1 
1 '?'
1      Request 'tar' to explain possible responses.
1 'q'
1      Request 'tar' to exit immediately.
1 'n FILE-NAME'
1      Request 'tar' to write the next volume on the file FILE-NAME.
1 '!'
1      Request 'tar' to run a subshell.  This option can be disabled by
1      giving '--restrict' command line option to 'tar'(2).
1 'y'
1      Request 'tar' to begin writing the next volume.
1 
1    (You should only type 'y' after you have changed the tape; otherwise
1 'tar' will write over the volume it just finished.)
1 
1    The volume number used by 'tar' in its tape-changing prompt can be
1 changed; if you give the '--volno-file=FILE-OF-NUMBER' option, then
1 FILE-OF-NUMBER should be an non-existing file to be created, or else, a
1 file already containing a decimal number.  That number will be used as
1 the volume number of the first volume written.  When 'tar' is finished,
1 it will rewrite the file with the now-current volume number.  (This does
11 not change the volume number written on a tape label, as per ⇒
 label, it _only_ affects the number used in the prompt.)
1 
1    If you want more elaborate behavior than this, you can write a
1 special "new volume script", that will be responsible for changing the
1 volume, and instruct 'tar' to use it instead of its normal prompting
1 procedure:
1 
1 '--info-script=COMMAND'
1 '--new-volume-script=COMMAND'
1 '-F COMMAND'
1      Specify the command to invoke when switching volumes.  The COMMAND
1      can be used to eject cassettes, or to broadcast messages such as
1      'Someone please come change my tape' when performing unattended
1      backups.
1 
1    The COMMAND can contain additional options, if such are needed.
1 ⇒Running External Commands external, for a detailed discussion of
1 the way GNU 'tar' runs external commands.  It inherits 'tar''s shell
1 environment.  Additional data is passed to it via the following
1 environment variables:
1 
1 'TAR_VERSION'
1      GNU 'tar' version number.
1 
1 'TAR_ARCHIVE'
1      The name of the archive 'tar' is processing.
1 
1 'TAR_BLOCKING_FACTOR'
1      Current blocking factor (⇒Blocking).
1 
1 'TAR_VOLUME'
1      Ordinal number of the volume 'tar' is about to start.
1 
1 'TAR_SUBCOMMAND'
11      A short option describing the operation 'tar' is executing.  ⇒
      Operations, for a complete list of subcommand options.
1 
1 'TAR_FORMAT'
1      Format of the archive being processed.  ⇒Formats, for a
1      complete list of archive format names.
1 
1 'TAR_FD'
1      File descriptor which can be used to communicate the new volume
1      name to 'tar'.
1 
1    These variables can be used in the COMMAND itself, provided that they
1 are properly quoted to prevent them from being expanded by the shell
1 that invokes 'tar'.
1 
1    The volume script can instruct 'tar' to use new archive name, by
1 writing in to file descriptor '$TAR_FD' (see below for an example).
1 
1    If the info script fails, 'tar' exits; otherwise, it begins writing
1 the next volume.
1 
1    If you want 'tar' to cycle through a series of files or tape drives,
1 there are three approaches to choose from.  First of all, you can give
1 'tar' multiple '--file' options.  In this case the specified files will
1 be used, in sequence, as the successive volumes of the archive.  Only
1 when the first one in the sequence needs to be used again will 'tar'
1 prompt for a tape change (or run the info script).  For example, suppose
1 someone has two tape drives on a system named '/dev/tape0' and
1 '/dev/tape1'.  For having GNU 'tar' to switch to the second drive when
1 it needs to write the second tape, and then back to the first tape,
1 etc., just do either of:
1 
1      $ tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 FILES
1      $ tar -cM -f /dev/tape0 -f /dev/tape1 FILES
1 
1    The second method is to use the 'n' response to the tape-change
1 prompt.
1 
1    Finally, the most flexible approach is to use a volume script, that
1 writes new archive name to the file descriptor '$TAR_FD'.  For example,
1 the following volume script will create a series of archive files, named
1 'ARCHIVE-VOL', where ARCHIVE is the name of the archive being created
1 (as given by '--file' option) and VOL is the ordinal number of the
1 archive being created:
1 
1      #! /bin/bash
1      # For this script it's advisable to use a shell, such as Bash,
1      # that supports a TAR_FD value greater than 9.
1 
1      echo Preparing volume $TAR_VOLUME of $TAR_ARCHIVE.
1 
1      name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
1      case $TAR_SUBCOMMAND in
1      -c)       ;;
1      -d|-x|-t) test -r ${name:-$TAR_ARCHIVE}-$TAR_VOLUME || exit 1
1                ;;
1      *)        exit 1
1      esac
1 
1      echo ${name:-$TAR_ARCHIVE}-$TAR_VOLUME >&$TAR_FD
1 
1    The same script can be used while listing, comparing or extracting
1 from the created archive.  For example:
1 
1      # Create a multi-volume archive:
1      $ tar -c -L1024 -f archive.tar -F new-volume .
1      # Extract from the created archive:
1      $ tar -x -f archive.tar -F new-volume .
1 
1 Notice, that the first command had to use '-L' option, since otherwise
1 GNU 'tar' will end up writing everything to file 'archive.tar'.
1 
1    You can read each individual volume of a multi-volume archive as if
1 it were an archive by itself.  For example, to list the contents of one
1 volume, use '--list', without '--multi-volume' specified.  To extract an
1 archive member from one volume (assuming it is described that volume),
1 use '--extract', again without '--multi-volume'.
1 
1    If an archive member is split across volumes (i.e., its entry begins
1 on one volume of the media and ends on another), you need to specify
1 '--multi-volume' to extract it successfully.  In this case, you should
1 load the volume where the archive member starts, and use 'tar --extract
1 --multi-volume'--'tar' will prompt for later volumes as it needs them.
1 ⇒extracting archives, for more information about extracting
1 archives.
1 
1    Multi-volume archives can be modified like any other archive.  To add
1 files to a multi-volume archive, you need to only mount the last volume
1 of the archive media (and new volumes, if needed).  For all other
1 operations, you need to use the entire archive.
1 
1    If a multi-volume archive was labeled using '--label=ARCHIVE-LABEL'
1 (⇒label) when it was created, 'tar' will not automatically label
1 volumes which are added later.  To label subsequent volumes, specify
1 '--label=ARCHIVE-LABEL' again in conjunction with the '--append',
1 '--update' or '--concatenate' operation.
1 
1    Notice that multi-volume support is a GNU extension and the archives
1 created in this mode should be read only using GNU 'tar'.  If you
1 absolutely have to process such archives using a third-party 'tar'
1 implementation, read ⇒Split Recovery.
1 
1    ---------- Footnotes ----------
1 
1    (1) If you run GNU 'tar' under a different locale, the translation to
1 the locale's language will be used.
1 
1    (2) ⇒--restrict, for more information about this option.
1