Commands‎ > ‎

Compare

Compare a list of files or directories with data stored in a backup directory.

$ hb compare [-c backupdir] [-v level] [-f] [-i attr1,attr2,...] -X
                  pathname [pathname ...]

Displays files and directories that have been added, changed, or removed since the most recent backup. New files are marked with +, removed files are marked with -, and changed files are marked with !. For changed files, the changes are listed after the pathname.

-v    control how much output is displayed, higher numbers for more:
  • -v0 = print version, backup directory, pathnames, changes, count of changes
  • -v1 = print names of skipped filesystems
  • -v2 = print detailed information about exactly what changed
  • -v3 = print names of excluded files
-f    generate a hash for each file and compare with the hash stored in the backup.  Differences are noted with data in the changed attribute list.  This option also forces a comparison of every inode attribute, even when it appears the file or directory has not been modified because ctime and inode have not changed.

-i
           ignore certain attributes (separated by commas, no spaces); attribute values are: ctime,gid,ino,mode,mtime,nlink,rdev,size,uid
 

-X    cross mount points (descend into other filesystems)

Examples

Example with no changes:

# hb compare -c /hb /System
HashBackup build 801 Copyright 2009-2012 HashBackup, LLC
Backup directory: /hb
This is backup version: 0
No files changed
No errors
#

Example with changes:

# hb compare -c /hb /Library
HashBackup build 801 Copyright 2009-2012 HashBackup, LLC
Backup directory: /hb
This is backup version: 0
! /Library/Keychains (mtime,ctime)
! /Library/Preferences (mtime,ctime)
! /Library/Preferences/com.apple.SoftwareUpdate.plist (ino,mtime,ctime)
! /Library/Printers (mtime,ctime)
! /Library/Printers/InstalledPrinters.plist (ino,size,mtime,ctime)
! /Library/Updates (mtime,ctime)
! /Library/Updates/ProductMetadata.plist (ino,mtime,ctime)
7 files changed
No errors
#


The same example, ignoring some attributes:


# hb compare -c /hb /Library -i mtime,ctime
HashBackup build 801 Copyright 2009-2012 HashBackup, LLC
Backup directory: /hb
This is backup version: 0
! /Library/Preferences/com.apple.SoftwareUpdate.plist (ino)
! /Library/Printers/InstalledPrinters.plist (ino,size)
! /Library/Updates/ProductMetadata.plist (ino)
3 files changed
No errors
#

Example showing new, changed, and removed files:


sh-3.2# hb compare -c /hb /private/etc
HashBackup build 801 Copyright 2009-2012 HashBackup, LLC
Backup directory: /hb
This is backup version: 0
! /private/etc (mtime,ctime)
! /private/etc/cups/certs (mtime,ctime)
! /private/etc/cups/certs/0 (ino,mtime,ctime)
! /private/etc/dnscache/log/main (mtime,ctime)
- /private/etc/dnscache/log/main/@4000000050c2a0560119f98c.s
- /private/etc/dnscache/log/main/@4000000050c2a0fb0e988ca4.s
+ /private/etc/dnscache/log/main/@4000000050c36a0a169fd4fc.s
+ /private/etc/dnscache/log/main/@4000000050c36a0e34b4ddd4.s
+ /private/etc/dnscache/log/main/@4000000050c36aa1297cc7ec.s
! /private/etc/dnscache/log/main/current (ino,size,mtime,ctime)
! /private/etc/hosts (ino,size,mtime,ctime)
- /private/etc/hosts.~24~
+ /private/etc/hosts.~26~
26 files changed
No errors

Notes
  • with -v0, a file or directory with the "nodump" bit set will display as added
  • with -v0, a new directory displays as added but its contents are not displayed
  • deleted directories display as removed, with ... added, but the contents are not displayed
  • extended attributes and ACLs should be compared when -f is used
  • symbolic link values should be compared when -f is used
  • compare exits with 1 if errors occur
  • compare should also exit with a non-zero error if any changes are detected, but exits with zero
Comments