efficient_backups_with_rsnapshot
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| efficient_backups_with_rsnapshot [2009/12/02 07:08] – Page name changed from quick_backup_from_windows_with_cygwin_rsync_to_linux to efficient_backups_with_rsnapshot tkbletsc | efficient_backups_with_rsnapshot [2010/07/12 06:04] (current) – tkbletsc | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| - | * Install cygwin with rsync and ssh | + | Basically, do this: http://troy.jdmz.net/rsnapshot/ |
| - | * Set up SSH keys | + | |
| - | * Associate | + | |
| - | * Make a script like this: | + | |
| - | < | + | Reminder: on debian/ubuntu, you need to "sudo apt-get install liblchown-perl" |
| - | #!/bin/sh | + | |
| - | date +" | + | In place of his rickety '' |
| - | rsync -auzv --delete | + | <code perl> |
| - | date +" | + | # |
| + | # Name: / | ||
| + | # Purpose: Restricts rsync to subdirectory declared in .ssh/ | ||
| + | # | ||
| + | # The client uses "rsync -av -e ssh src/ server: | ||
| + | # executes this program when .ssh/ | ||
| + | # For example: | ||
| + | # command=" | ||
| + | # command=" | ||
| + | # The former limits the remote client to a specific subdirectory of " | ||
| + | # and the latter allows read-only access to a different dirctory. | ||
| + | |||
| + | 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 = "$top1/"; | ||
| + | |||
| + | my $command = $ENV{SSH_ORIGINAL_COMMAND}; | ||
| + | die "Not invoked via sshd\n$Usage" | ||
| + | |||
| + | my ($cmd, | ||
| + | die " | ||
| + | die " | ||
| + | if $ro and $cmd !~ / | ||
| + | |||
| + | my $dir = $requested_target; | ||
| + | $dir =~ tr|-~\\ _/a-zA-Z0-9.,:@|_|c; | ||
| + | $dir =~ s%/\.\.(?=/)%__%g; # Don't allow foo/../../etc | ||
| + | |||
| + | # For "foo", allow " | ||
| + | # For " | ||
| + | # path and " | ||
| + | |||
| + | my($target, | ||
| + | if ("/ | ||
| + | $target | ||
| + | } elsif ("/ | ||
| + | $target | ||
| + | } elsif ($dir eq $top1 or index($dir, | ||
| + | $target | ||
| + | } 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. | ||
| </ | </ | ||
| - | * Set up a " | + | For Windows targets, install cygwin' |
| + | |||
| + | backup windowsuser@windowsbox-rsnapshot:/ | ||
efficient_backups_with_rsnapshot.1259766497.txt.gz · Last modified: by tkbletsc
