#!/usr/bin/perl # $Id: rsync_snapshot_receiver 388 2005-11-09 18:33:10Z jhealy $ # =head1 NAME rsync_snapshot_receiver =head1 SYNOPSIS ./rsync_snapshot_sender config-file =head1 ABSTRACT Receives a full-incremental backup sent from a remote computer, and stores it using hard links. This script assumes that the source machine has sent the files via the L script. See L for more information. =head1 DESCRIPTION This script uses rsync to receive and store a set of files sent from a remote machine running the L script. If you just want to back up files to the local machine, use L instead. Simply invoke the script with the name of the configuration file to use to store this particular backup. To specify a different configuration file, you must have some external mechanism that calls this script with the correct configuration file as its argument. We recommend using SSH public/private keys to accomplis this. 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 run as a daemon, so disable logging to STDOUT $RsyncSnapshot::LOG_STDOUT = 0; # This script is a receiver, so only run receiver code in the conf file $RsyncSnapshot::RECEIVER = 1; if ($#ARGV != 0) { logDie("\nMust supply a SINGLE configuration files as argument.\n\n"); } foreach my $conffile (@ARGV) { unless (parseConfig($conffile)) { next; } debug("Receiving 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 rsyncReceiver("$BACKUP_ROOT/$DEST", $lastBackup, \%RSYNC_OPTIONS); debug("Finished receiving backup for $CONFIG_DESCRIPTION\n", 0); } =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