#!/usr/bin/perl # $Id: rsync_snapshot_local 388 2005-11-09 18:33:10Z jhealy $ # =head1 NAME rsync_snapshot_local =head1 SYNOPSIS ./rsync_snapshot_local config-file [config-file-2 ... config-file-N] =head1 ABSTRACT Performs a full-incremental backup using hard links. This script assumes that the source and destination files reside on the same host. See L for more information. =head1 DESCRIPTION This script uses rsync to back up a set of directories to a specified location on the same host. If you need to back up to a remote computer, you will need to use the L and L scripts. Simply invoke the script with the names of one or more configuration files as the arguments. The script will process each config file in turn and perform the backup specified therein. For more information, refer to the online documentation for this package: L =cut # Report errors well use strict; use warnings; use RsyncSnapshot ':subs', ':vars'; # This script is both a sender and a receiver, so run all code in # user conf files $RsyncSnapshot::SENDER = 1; $RsyncSnapshot::RECEIVER = 1; if ($#ARGV < 0) { logDie("\nMust supply a list of configuration files as arguments.\n\n"); } foreach my $conffile (@ARGV) { unless (parseConfig($conffile)) { next; } # This is a local-only version of the script, so unset any network options $SSH_HOST = undef; $SSH_USER = undef; $SSH_KEY = undef; debug("Starting backup for $CONFIG_DESCRIPTION\n", 0); # rotate the backup directories my $lastBackup = undef; if (defined($LINKDEST)) { $lastBackup = $LINKDEST; if( -d $lastBackup ) { debug("Using config value of $LINKDEST as hard-link target\n", 0); } elsif ($lastBackup eq '') { # The config file specified no hard links should be used by using # the special empty value. This is not an error, so we just silently # drop the link dir param $lastBackup = undef; } else { logWarn("Config-specified hardlink dir could not be found!\n" . "Proceeding with backup, but no hard links will be used.\n"); $lastBackup = undef; } } else { $lastBackup = rotateDirectories(); } # run the rsync command my %results = (); foreach my $source (@SOURCES) { splitRsync($SPLIT, $source, "$BACKUP_ROOT/$DEST", $lastBackup, \%RSYNC_OPTIONS, \%results, @RSYNC_EXCLUDES); } debug("Finished backup for $CONFIG_DESCRIPTION\n", 0); printResults(%results); } =head1 SEE ALSO Full documentation for this package is located on the web: L =head1 AUTHOR Jason Healy, Suffield Academy =head1 COPYRIGHT AND LICENSE Copyright 2005 by Jason Healy This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut