tar-snapshot-edit.texi 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. @c This is part of the paxutils manual.
  2. @c Copyright (C) 2007--2023 Free Software Foundation, Inc.
  3. @c This file is distributed under GFDL 1.1 or any later version
  4. @c published by the Free Software Foundation.
  5. @cindex Device numbers, changing
  6. @cindex snapshot files, editing
  7. @cindex snapshot files, fixing device numbers
  8. Various situations can cause device numbers to change: upgrading your
  9. kernel version, reconfiguring your hardware, loading kernel modules in a
  10. different order, using virtual volumes that are assembled dynamically
  11. (such as with @acronym{LVM} or @acronym{RAID}), hot-plugging drives
  12. (e.g. external USB or Firewire drives), etc. In the majority of
  13. cases this change is unnoticed by the users. However, it influences
  14. @command{tar} incremental backups: the device number is stored in tar
  15. snapshot files (@pxref{Snapshot Files}) and is used to determine whether
  16. the file has changed since the last backup. If the device numbers
  17. change for some reason, by default the next backup you run will be a
  18. full backup.
  19. @pindex tar-snapshot-edit
  20. To minimize the impact in these cases, GNU @command{tar} comes with
  21. the @command{tar-snapshot-edit} utility for inspecting and updating
  22. device numbers in snapshot files. (The utility, written by
  23. Dustin J.@: Mitchell, is also available from the
  24. @uref{http://www.gnu.org/@/software/@/tar/@/utils/@/tar-snapshot-edit.html,
  25. @GNUTAR{} home page}.)
  26. To obtain a summary of the device numbers found in the snapshot file, run
  27. @smallexample
  28. $ @kbd{tar-snapshot-edit @var{snapfile}}
  29. @end smallexample
  30. @noindent
  31. where @var{snapfile} is the name of the snapshot file (you can supply as many
  32. files as you wish in a single command line). You can then compare the
  33. numbers across snapshot files, or against those currently in use on the
  34. live filesystem (using @command{ls -l} or @command{stat}).
  35. Assuming the device numbers have indeed changed, it's often possible
  36. to simply tell @GNUTAR{} to ignore the device number when processing the
  37. incremental snapshot files for these backups, using the
  38. @option{--no-check-device} option (@pxref{device numbers}).
  39. Alternatively, you can use the @command{tar-edit-snapshot} script's
  40. @option{-r} option to update all occurrences of the given device
  41. number in the snapshot file(s). It takes a single argument
  42. of the form
  43. @samp{@var{olddev}-@var{newdev}}, where @var{olddev} is the device number
  44. used in the snapshot file, and @var{newdev} is the corresponding new device
  45. number. Both numbers may be specified in hex (e.g., @samp{0xfe01}),
  46. decimal (e.g., @samp{65025}), or as a major:minor number pair (e.g.,
  47. @samp{254:1}). To change several device numbers at once, specify them
  48. in a single comma-separated list, as in
  49. @option{-r 0x3060-0x4500,0x307-0x4600}.
  50. Before updating the snapshot file, it is a good idea to create a backup
  51. copy of it. This is accomplished by @samp{-b} option. The name of the
  52. backup file is obtained by appending @samp{~} to the original file name.
  53. An example session:
  54. @smallexample
  55. $ @kbd{tar-snapshot-edit root_snap.0 boot_snap.0}
  56. File: root_snap.0
  57. Detected snapshot file version: 2
  58. Device 0x0000 occurs 1 times.
  59. Device 0x0003 occurs 1 times.
  60. Device 0x0005 occurs 1 times.
  61. Device 0x0013 occurs 1 times.
  62. Device 0x6801 occurs 1 times.
  63. Device 0x6803 occurs 6626 times.
  64. Device 0xfb00 occurs 1 times.
  65. File: boot_snap.0
  66. Detected snapshot file version: 2
  67. Device 0x6801 occurs 3 times.
  68. $ @kbd{tar-snapshot-edit -b -r 0x6801-0x6901,0x6803-0x6903 root_snap.0 boot_snap.0}
  69. File: root_snap.0
  70. Detected snapshot file version: 2
  71. Updated 6627 records.
  72. File: boot_snap.0
  73. Detected snapshot file version: 2
  74. Updated 3 records.
  75. @end smallexample