Directory Snapshot

Some of the small programs I wrote on my spare time. They are Free Software, and written mostly in OCaml.
Post Reply
User avatar
Vincent
Posts: 3077
Joined: Fri Apr 07, 2006 12:10 pm
Location: Schtroumpf
Contact:

Directory Snapshot

Post by Vincent » Sun Sep 14, 2008 5:30 pm

Download:
Directory_Snapshot.tar.gz
(173.45 KiB) Downloaded 1139 times
windows version: here

Language: Objective Caml

License: GNU GPL

OS: Any

Description:
This utility can take snapshots of directories (tree representations with file names and stats, but not contents), and compare snapshots of the same directory looking for differences in stats: for instance modification date etc. It is quite fast (on my system, taking and comparing snaps of my home folder (6700 files in 500 folders) takes 90ms and 70ms respectively).

Usage:

Code: Select all

usage: dsnap [options] <command>

Basic Commands:

  snap <dir> to <path>
    Create a snapshot of directory <dir>, stored in file <path>

  diff <snap1> <snap2>
    Compare two snapshots, looking for most kinds of differences.
    See the 'diff ... for ...' syntax for more information

  list <snap>
    Print the list of all files tracked in the snapshot

  read <snap>
    Same as 'list', but the names are organized by folder

Advanced Commands:

  diff <s1> <s2> for [flags list]
    Compare two snapshots, looking for specific kinds of differences.
    See below for a list of flags.

  snap <dir> to <new_snapshot> diff <old_snapshot> [for [flags list]]
    Combination of the 'snap', 'diff' and optionally, 'for' syntaxes.

Available flags:

Simple flags:
  [unstable flags - apply to new or deleted elements]

  dir_erased      : see which folders have disappeared
  dir_created     : see new folders
  file_erased     : see which files have disappeared
  file_created    : see new files

  [stable flags   - apply to elements in both snapshots]

  modif           : see modified files
  access          : see accessed files
  status          : see files whose status has changed
  size            : see files whose size has changed
  group           : see files with changed group ownership
  user            : see files with changed ownership
  perm            : see files with changed permissions

Composite flags:
  dir             : dir_*
  file            : file_*
  erased          : *_erased
  created         : *_created
  uflags          : dir_* file_*
  sflags          : modif access status size group user perm
  default         : uflags modif user group
  all             : uflags sflags

Options:
  --follow-symlinks-dirs  (-l)
    When taking a snapshot, don't follow symlinks pointing to folders

  --follow-symlinks-files (-lf)
    When taking a snapshot, don't follow symlinks pointing to ordinary files

  --follow-symlinks       (-L)
    When taking a snapshot, don't follow any symlink

  --help                  (-h, -?)
    Display this help page and exit
Example session:

Code: Select all

vincent@seth:~$ dsnap -L snap ~ to snap_before
# here I change the setting I'm interested in...
vincent@seth:~$ dsnap -L snap ~ to snap_after
vincent@seth:~$ dsnap diff snap_before snap_after
Snapshot diff on directory '/home/vincent'
file modified: /home/vincent/.kderc
file modified: /home/vincent/snap_before
file modified: /home/vincent/.kde/share/apps/kdesktop/IconPositions
file erased : /home/vincent/.kde/share/config/gtkrc
file erased : /home/vincent/.kde/share/config/gtkrc-2.0
file modified: /home/vincent/.kde/share/config/kcmfonts
file modified: /home/vincent/.kde/share/config/kdeglobals
file modified: /home/vincent/.kde/share/config/kdesktoprc
file modified: /home/vincent/.kde/share/config/kwinrc
file modified: /home/vincent/.kde/share/config/systemsettingsrc
file modified: /home/vincent/.qt/qtrc
{ Vincent Hugot }

User avatar
Vincent
Posts: 3077
Joined: Fri Apr 07, 2006 12:10 pm
Location: Schtroumpf
Contact:

Re: Directory Snapshot

Post by Vincent » Tue Sep 16, 2008 1:03 am

Note to self:

should add an option to show files created contained in newly created directories. (instead of just saying "directory created: /foo/bar")

could add an option to store file hash to detect content modification in addition of mere modif date change. (of course taking snaps with this option on would take muuuuuuch longer for little added value. No impact on comparison though.)
{ Vincent Hugot }

User avatar
Vincent
Posts: 3077
Joined: Fri Apr 07, 2006 12:10 pm
Location: Schtroumpf
Contact:

Re: Directory Snapshot

Post by Vincent » Tue Sep 16, 2008 8:14 pm

Notes:

could add a feature to expand a snapshot to disk, creating files with the same hierarchy, but with stats instead of the original contents.

could add feature to remove the prefix from a snapshot.

put in an option to skip directories you can't read

Code: Select all

vincent@seth:~$ dsnap snap / to x -L
Fatal error: exception Sys_error("//etc/cups/ssl: Permission denied")
{ Vincent Hugot }

User avatar
Vincent
Posts: 3077
Joined: Fri Apr 07, 2006 12:10 pm
Location: Schtroumpf
Contact:

Re: Directory Snapshot

Post by Vincent » Sat Sep 27, 2008 7:05 pm

Download for Windows:
dsnap.exe.tar.gz
(142.25 KiB) Downloaded 1211 times
(exe compiled from virtual XP box on my Linux system; snaps taken with windows version can be used with linux version and vice-versa)
{ Vincent Hugot }

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 25 guests