[Dirvish] [patch] local to remote backup; dirvish push
Robert Siemer
Robert.Siemer-dirvish at backsla.sh
Mon Aug 28 21:36:20 UTC 2006
Hello everyone!
Right now dirvish can only save files local to local and remote to local.
What my patch does is to allow the local to remote case hidden in the
first one (local to local). This needs two steps:
1. to have a local representation of the remote bank (e.g. sshfs
mounted), but
2. to also hint rsync to do real local to remote transfers
The first step could be used alone to let dirvish handle it like "local
to local", but in the rsync phase of dirvish it would basically copy
over the network instead of transfering only checksums. And this is what
I chose dirvish for: the benefits of rsync, so I don't want to lose
them.
My patch addresses:
* calls rsync with a relative --link-dest path instead of an
absolute one (as my first patch got no response I include this
funtionality here again)
* adapts the 'bank:' option to enable the naming of two points to
access the remote bank (a local and the remote representation).
Further information at http://backsla.sh/backup
Comments?
Bye,
Robert
-------------- next part --------------
--- dirvish.local 2006-07-27 18:25:25.000000000 +0200
+++ dirvish 2006-08-28 22:12:35.000000000 +0200
@@ -17,6 +17,10 @@
# Copyright 2002 and $Date: 2004/02/25 02:42:15 $
# Pegasystems Technologies and J.W. Schultz #
# #
+# Modified by <Robert.Siemer-dirvish at backsla.sh>: #
+# -allow backup push with 'bank: local remote' option #
+# -make rsync --link-dest relative #
+# #
# Licensed under the Open Software License version 2.0 #
# #
# This program is free software; you can redistribute it #
@@ -284,19 +288,8 @@
ref($$Options{$key}) eq 'CODE' and usage("$key undefined");
}
-if(!$$Options{Bank})
-{
- my $bank;
- for $bank (@{$$Options{bank}})
- {
- if (-d "$bank/$$Options{vault}")
- {
- $$Options{Bank} = $bank;
- last;
- }
- }
- $$Options{Bank} or seppuku 220, "ERROR: cannot find vault $$Options{vault}";
-}
+create_OptionsBank;
+$$Options{Bank} or seppuku 220, "ERROR: cannot find vault $$Options{vault}";
$vault = join('/', $$Options{Bank}, $$Options{vault});
-d $vault or seppuku 221, "ERROR: cannot find vault $$Options{vault}";
@@ -427,7 +420,8 @@
$aliastree ||= $srctree;
$destree = join("/", $vault, $image, 'tree');
-$reftree = join('/', $vault, $$Options{Reference}, 'tree');
+# the $reftree is relative to the $destree -Robert
+$reftree = join("/", '../..', $$Options{Reference}, 'tree');
$err_temp = join("/", $vault, $image, 'rsync_error.tmp');
$err_file = join("/", $vault, $image, 'rsync_error');
$log_file = join("/", $vault, $image, 'log');
@@ -526,7 +520,9 @@
($$Options{rsync} ? $$Options{rsync} : 'rsync'),
@rsyncargs,
$rclient . $srctree . '/',
- $destree
+ ($$Options{RemoteBank} ?
+ join("/", $$Options{RemoteBank} . $$Options{vault}, $image, 'tree') :
+ $destree)
);
printf SUMMARY "\n%s: %s\n", 'ACTION', join (' ', @cmd);
@@ -833,6 +829,32 @@
exit 0;
+sub create_OptionsBank
+{
+ if(!$$Options{Bank})
+ {
+ my ($bank, $remotebank, $splitbank);
+ for $bank (@{$$Options{bank}})
+ {
+ ($splitbank, $remotebank) = split(/\s+/, $bank);
+ if (-d "$bank/$$Options{vault}")
+ {
+ $$Options{Bank} = $bank;
+ last;
+ }
+ elsif (-d "$splitbank/$$Options{vault}")
+ {
+ $$Options{Bank} = $splitbank;
+ # 'server.de:' and 'server.de:dir/' is okay, rest needs
+ # slash... -Robert
+ $remotebank =~ s|([^:/])$|\1/|;
+ $$Options{RemoteBank} = $remotebank;
+ last;
+ }
+ }
+ }
+}
+
sub errorscan
{
my ($status, $err_file, $err_temp) = @_;
@@ -1088,18 +1110,7 @@
{
if(!$modes{g} && $$Options{vault} && $$Options{vault} ne 'CODE')
{
- if(!$$Options{Bank})
- {
- my $bank;
- for $bank (@{$$Options{bank}})
- {
- if (-d "$bank/$$Options{vault}")
- {
- $$Options{Bank} = $bank;
- last;
- }
- }
- }
+ create_OptionsBank;
if ($$Options{Bank})
{
$confile = join('/', $$Options{Bank},
More information about the Dirvish
mailing list