efficient_backups_with_rsnapshot
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| efficient_backups_with_rsnapshot [2009/12/02 07:24] – tkbletsc | efficient_backups_with_rsnapshot [2010/07/12 06:04] (current) – tkbletsc | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Efficient backups with rsnapshot ====== | ====== Efficient backups with rsnapshot ====== | ||
| - | (I need to write a full article here, but I don't have time now. | + | Basically, do this: http://troy.jdmz.net/rsnapshot/ |
| - | ===== Backing up Windows hosts ===== | + | Reminder: on debian/ |
| - | Normally, all you'd need to do to make the server back up Windows hosts is to install Cygwin with SSH and rsync and set up SSH keys as normal. | + | In place of his rickety |
| + | <code perl> | ||
| + | # | ||
| + | # Name: / | ||
| + | # Purpose: Restricts | ||
| + | # | ||
| + | # The client uses "rsync -av -e ssh src/ server: | ||
| + | # executes | ||
| + | # For example: | ||
| + | # command=" | ||
| + | # command=" | ||
| + | # The former limits the remote client | ||
| + | # and the latter allows read-only access to a different dirctory. | ||
| - | So we'll set up **rsyncd**, the dedicated rsync service. | + | use Socket; |
| + | use constant LOGFILE => '/ | ||
| + | my $Usage = << | ||
| + | Use ' | ||
| + | in front of lines in $ENV{HOME}/ | ||
| + | EOM | ||
| - | First, install Cygwin with rsync and anything else you might like. | + | # Format of the envrionment variables set by sshd: |
| + | # SSH_ORIGINAL_COMMAND=rsync --server | ||
| + | # SSH_ORIGINAL_COMMAND=rsync --server --sender -vlogDtpr --partial . dir # pull | ||
| + | # SSH_CLIENT=client_addr client_port server_port | ||
| - | Second, set up rsyncd as a service: | + | my $ro = (@ARGV and $ARGV[0] eq ' |
| + | my $top1 = shift; | ||
| + | die "No subdirectory specified\n$Usage" | ||
| + | my $top2 = " | ||
| - | | + | my $command = $ENV{SSH_ORIGINAL_COMMAND}; |
| + | die "Not invoked via sshd\n$Usage" | ||
| - | Third, set up '' | + | my ($cmd,$requested_target) = $command =~ /(.* \.) ?(.*)/; |
| + | die " | ||
| + | die "$0 -ro: sending to read-only directory $requested_target not allowed\n" | ||
| + | if $ro and $cmd !~ /^rsync --server --sender /; | ||
| - | < | + | my $dir = $requested_target; |
| - | uid = nobody | + | $dir =~ tr|-~\\ _/a-zA-Z0-9.,: |
| - | gid = nobody | + | $dir =~ s%/\.\.(?=/)%__%g; |
| - | use chroot = no | + | |
| - | max connections = 4 | + | |
| - | syslog facility = local5 | + | |
| - | pid file = /var/ | + | |
| - | read only = true | + | |
| - | hosts allow = < | + | |
| - | + | ||
| - | [root] | + | |
| - | path = / | + | |
| - | auth users = < | + | |
| - | secrets file = /etc/rsyncd.secrets | + | |
| - | </file> | + | |
| - | Populate the user list '' | + | # For " |
| + | # For " | ||
| + | # path and " | ||
| - | < | + | my($target, |
| - | < | + | if ("/ |
| - | </file> | + | |
| + | } elsif ("/$dir" eq substr($top2, | ||
| + | $target = $top2; | ||
| + | } elsif ($dir eq $top1 or index($dir, | ||
| + | $target = $dir; # Exact match or subdirectory | ||
| + | } elsif (substr($dir, | ||
| + | $target = " | ||
| + | $forced = 1; | ||
| + | } else { | ||
| + | $target = " | ||
| + | $forced = 1; | ||
| + | } | ||
| - | Then, on the backup server, create a file '' | + | $target =~ s#^//#/#; # program is dumb and sets root to '//' |
| - | <file> | + | if (-f LOGFILE and open LOG,'>>', |
| - | < | + | my $hhmm = sprintf " |
| - | </file> | + | my $host = $ENV{SSH_CLIENT} || ' |
| + | $host =~ s/ .*//; # Keep only the client' | ||
| + | $host = gethostbyaddr(inet_aton($host), | ||
| + | $_ = sprintf " | ||
| + | print LOG "$hhmm $_ [$command] =", | ||
| + | close LOG; | ||
| + | } | ||
| - | Now you can add backup lines to your rsnapshot.conf as follows: | + | exec "$cmd $target" |
| + | # Note: This assumes that the rsync protocol will not be maliciously hijacked. | ||
| + | </ | ||
| - | backup rsync://< | + | For Windows targets, install cygwin' |
| - | The < | + | |
| - | + | ||
| - | If you want to back up something like your Firefox profile that will have certain files locked, exclude those files. | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | Remember that you don't need to escape spaces, since fields in this line are tab-separated. | + | |
efficient_backups_with_rsnapshot.1259767493.txt.gz · Last modified: by tkbletsc
