Mike Heins
and 1 contributors


snapcopy -- copy Snapback directories efficiently


 snapcopy [-v] [-R rsync] [-r path] srcdir [srcdir2 ..] targdir


When you want to maintain a disk backup created by snapback, you may find that trying to copy the directory structure to another disk doesn't work very well. The cp command doesn't know how to find the hard links which make snapback2 work so well, and the space savings will be lost.

This script efficiently does a copy to another disk via rsync. It scans a tree with File::Find, grabs the hourly/daily/weekly/monthly directory names, and checks their time stamp. It copies the earliest one first (no matter its name) and then uses rsync(1) and its --link-dest option to avoid using disk space on a copy of identical files.

Note that some permissions may not be preserved.



Show what would be done by echoing the commands as they would be run. (Though this script uses File::Path and its mkpath() routine to avoid dependence on a specific mkdir(1), it echos the command as if it was using mkdir.)

No file system modification of any kind is done, but the paths are traversed to find .


Verbose, passed as -v flag to rsync and mkpath().

-r /path/to/rm

The easiest way to run snapcopy is to change directory to the root of the tree you want to copy and specify directories as a relative path. But if you want to specify the source directories as absolute paths, you may want to trim off a leading path component. The -r argument will be removed from the front of the target directory fragment that goes after the base target directory.

-R /path/to/rsync

Normally the first "rsync" found in your path is used as the rsync command. If your rsync lives somewhere outside your path, specify it here.


If you have a backup volume mounted at /mnt/backup1, and you wish to copy some web server backups to /mnt/backup2 so you can do maintenance on the disk at /mnt/backup1, you can run from the command line:

        % cd /mnt/backup1
        % snapcopy www.perusion.com www.icdevgroup.org /mnt/backup2

You will find the copies in /mnt/backup2/www.perusion.com, etc.

If you want to do the same thing without changing directory, you can do:

        % snapcopy /mnt/backup1/www.perusion.com \
                           /mnt/backup1/www.icdevgroup.org /mnt/backup2

That will, however, create the directories:


You can match the behavior of the first example with:

        % snapcopy -r /mnt/backup1 /mnt/backup1/www.perusion.com \
                           /mnt/backup1/www.icdevgroup.org /mnt/backup2


Probably some. Permissions may not be totally preserved depending on your original options to Snapback when you ran it.

No provision for sending to a remote system with SSH.


Mike Heins, Perusion, <snapback@perusion.org>.