efficient_backups_with_rsnapshot
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| efficient_backups_with_rsnapshot [2010/07/12 06:04] – tkbletsc | efficient_backups_with_rsnapshot [2026/02/21 08:58] (current) – tkbletsc | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Efficient backups with rsnapshot ====== | ====== Efficient backups with rsnapshot ====== | ||
| - | Basically, do this: http://troy.jdmz.net/rsnapshot/ | + | Basically, do this: [[https://documentation.ubuntu.com/server/ |
| - | Reminder: on debian/ | + | Reminder: on debian/ |
| - | In place of his rickety '' | + | To restrict the ability |
| - | <code perl> | + | |
| - | #!/usr/bin/perl | + | |
| - | # Name: / | + | |
| - | # Purpose: Restricts rsync to subdirectory declared in .ssh/authorized_keys | + | |
| - | # | + | |
| - | # The client uses "rsync -av -e ssh src/ server: | + | |
| - | # executes this program when .ssh/ | + | |
| - | # For example: | + | |
| - | # command=" | + | |
| - | # command=" | + | |
| - | # The former limits | + | |
| - | # | + | |
| - | use Socket; | ||
| - | use constant LOGFILE => '/ | ||
| - | my $Usage = << | ||
| - | Use ' | ||
| - | in front of lines in $ENV{HOME}/ | ||
| - | EOM | ||
| - | # 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 | ||
| - | |||
| - | 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" | ||
| - | |||
| - | my ($cmd, | ||
| - | 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; | ||
| - | $dir =~ tr|-~\\ _/ | ||
| - | $dir =~ s%/ | ||
| - | |||
| - | # For " | ||
| - | # For " | ||
| - | # path and " | ||
| - | |||
| - | my($target, | ||
| - | if ("/ | ||
| - | $target = $top1; | ||
| - | } elsif ("/ | ||
| - | $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; | ||
| - | } | ||
| - | |||
| - | $target =~ s#^//#/#; # program is dumb and sets root to '//' | ||
| - | |||
| - | if (-f LOGFILE and open LOG,'>>', | ||
| - | my $hhmm = sprintf " | ||
| - | my $host = $ENV{SSH_CLIENT} || ' | ||
| - | $host =~ s/ .*//; # Keep only the client' | ||
| - | $host = gethostbyaddr(inet_aton($host), | ||
| - | $_ = sprintf " | ||
| - | print LOG "$hhmm $_ [$command] =", | ||
| - | close LOG; | ||
| - | } | ||
| - | |||
| - | exec "$cmd $target" | ||
| - | # Note: This assumes that the rsync protocol will not be maliciously hijacked. | ||
| - | </ | ||
| - | |||
| - | For Windows targets, install cygwin' | ||
| - | |||
| - | backup windowsuser@windowsbox-rsnapshot:/ | ||
efficient_backups_with_rsnapshot.txt · Last modified: by tkbletsc
