Ls

Lists contents of a backup.

$ hb ls [-c backupdir] [-l] [-v] [-r version] [-1]
        [-a] [-d] [pattern]

Without options, lists the most recent version of all files, not including deleted files.

Options

The -l (el) option shows more details similar to the Unix ls -l command, including the file modification time, backup time, and version number.

The -v option must be used with -l, and shows even more details.

The -r option selects a specific version to display and lists files that are backed up at this version or an earlier version. With -r1, some of the files may be from version 1 and some may be from version zero.

The -1 (one) option shows only the files backed up in the -r version, without showing previously saved files.

The -a option displays all versions of matching files, including deleted files. For example, the file /etc/hosts might be backed up in versions 2 and 3. Without -a, only the most recent version is listed. With -a, all versions are listed.

The -d options shows all versions of directory pathnames. These are normally not shown, even with -a. -d automatically enables -a.

Patterns

The optional file selection pattern displays all pathnames matching the pattern. A pattern may contain wildcards or not. Matching is case-sensitive. Non-wildcard patterns match whole pathname components, for example:

Pattern

Matches

Doesn’t Match

abcd

/abcd
/home/abcd
/home/abcd/file1

/home/abcd.txt
/abcdefg

test/file7

/test/file7
/etc/test/file7
/home/test/file7/x

/mytest/file7
/test/file70
/tester/file7

If the pattern begins with a slash, ls shows only the matches beginning at the root. If you’re not sure where a pathname is located, omit the leading slash. If the pathname begins with ./ (dot slash), ls adds the current directory to the beginning of the pattern.

Wildcards

A wildcard pattern uses Unix "glob" rules:

  • * matches zero or more characters

  • ? matches any single character

  • [x5] matches 1 character, either x or 5

  • [^x5] matches 1 character except x or 5

  • [a-z] matches one lowercase letter

  • [^0-9] matches one non-digit character

Wildcard pattern examples:

Pattern

Matches

Doesn’t Match

abcd*

/abcd
/abcdefg
/home/abcd
/home/abcdefg/xyz

/home/myabcd
/Users/yourabcdefg

*abcd*

Hint: a leading wildcard is slower.

/abcd
/abcdefg
/home/abcd
/home/abcdefg/xyz
/home/myabcd
/home/myabcdefg

/home/myabcs

/Users/*/.*

/Users/jim/.profile
/Users/jane/.emacs

/Users/.emacs
/home/jim/.profile

Wildcards must be quoted with single quotes on the command line.

Directories are only listed 1 level deep by default. If you want to list all files under a directory, similar to the Unix find command, add '/*' (in single quotes!) to the end of the pattern.

Examples

$ hb ls -c hb -l
HashBackup build #1666 Copyright 2009-2016 HashBackup, LLC
Backup directory: /hb
Most recent backup version: 0
Showing most recent version
   0 drwxrwxr-t   44    0   80     1564 2016-10-12 00:30:04 2016-10-12 13:27:46 /  (parent, partial)
(Scroll this area left or right to see all fields)

The fields are:

  • version number

  • Unix permissions

  • number of links

  • user id

  • group id

  • file size

  • date modified (mtime)

  • date backed up

  • path name

  • HashBackup notes

Adding -v gives more details:

$ hb ls -c hb -lv
HashBackup build #1666 Copyright 2009-2016 HashBackup, LLC
Backup directory: /hb
Most recent backup version: 0
Showing most recent version
   0 drwxrwxr-t   44    0   80     1564 2016-10-12 00:30:04 2016-10-12 13:27:46 /  (parent, partial)
            2 2016-10-12 00:30:04          1
   0 -rw-r--r--    1  501   20      511 2016-10-12 13:27:39 2016-10-12 13:27:46 /hb/inex.conf
      5700934 2016-10-12 13:27:39          6                              [dc4094a430afa32b82247a118b23e56c64ee095a]
(Scroll this area left or right to see all fields)

The fields are the same for the first line, then on the second line:

  • inode number

  • inode change time (ctime)

  • HashBackup file id

  • file hash (SHA1 for non-sparse files)