tar: Fixing Snapshot Files

1 
1 Appendix D Fixing Snapshot Files
1 ********************************
1 
1 Various situations can cause device numbers to change: upgrading your
1 kernel version, reconfiguring your hardware, loading kernel modules in a
1 different order, using virtual volumes that are assembled dynamically
1 (such as with LVM or RAID), hot-plugging drives (e.g.  external USB or
1 Firewire drives), etc.  In the majority of cases this change is
1 unnoticed by the users.  However, it influences 'tar' incremental
1 Snapshot Files::) and is used to determine whether the file has changed
1 since the last backup.  If the device numbers change for some reason, by
1 default the next backup you run will be a full backup.
1 
1    To minimize the impact in these cases, GNU 'tar' comes with the
1 'tar-snapshot-edit' utility for inspecting and updating device numbers
1 in snapshot files.  (The utility, written by Dustin J. Mitchell, is also
1 available from the GNU 'tar' home page
1 (http://www.gnu.org/software/tar/utils/tar-snapshot-edit.html).)
1 
1    To obtain a summary of the device numbers found in the snapshot file,
1 run
1 
1      $ tar-snapshot-edit SNAPFILE
1 
1 where SNAPFILE is the name of the snapshot file (you can supply as many
1 files as you wish in a single command line).  You can then compare the
1 numbers across snapshot files, or against those currently in use on the
1 live filesystem (using 'ls -l' or 'stat').
1 
1    Assuming the device numbers have indeed changed, it's often possible
1 to simply tell GNU 'tar' to ignore the device number when processing the
1 incremental snapshot files for these backups, using the
1 '--no-check-device' option (⇒device numbers).
1 
1    Alternatively, you can use the 'tar-edit-snapshot' script's '-r'
1 option to update all occurrences of the given device number in the
1 snapshot file(s).  It takes a single argument of the form
1 'OLDDEV-NEWDEV', where OLDDEV is the device number used in the snapshot
1 file, and NEWDEV is the corresponding new device number.  Both numbers
1 may be specified in hex (e.g., '0xfe01'), decimal (e.g., '65025'), or as
1 a major:minor number pair (e.g., '254:1').  To change several device
1 numbers at once, specify them in a single comma-separated list, as in
1 '-r 0x3060-0x4500,0x307-0x4600'.
1 
1    Before updating the snapshot file, it is a good idea to create a
1 backup copy of it.  This is accomplished by '-b' option.  The name of
1 the backup file is obtained by appending '~' to the original file name.
1 
1    An example session:
1      $ tar-snapshot-edit root_snap.0 boot_snap.0
1      File: root_snap.0
1        Detected snapshot file version: 2
1 
1        Device 0x0000 occurs 1 times.
1        Device 0x0003 occurs 1 times.
1        Device 0x0005 occurs 1 times.
1        Device 0x0013 occurs 1 times.
1        Device 0x6801 occurs 1 times.
1        Device 0x6803 occurs 6626 times.
1        Device 0xfb00 occurs 1 times.
1 
1      File: boot_snap.0
1        Detected snapshot file version: 2
1 
1        Device 0x6801 occurs 3 times.
1      $ tar-snapshot-edit -b -r 0x6801-0x6901,0x6803-0x6903 root_snap.0 boot_snap.0
1      File: root_snap.0
1        Detected snapshot file version: 2
1 
1        Updated 6627 records.
1 
1      File: boot_snap.0
1        Detected snapshot file version: 2
1 
1        Updated 3 records.
1