Created
February 6, 2015 05:23
-
-
Save techwolf359/35d7e2843b260efbfefe to your computer and use it in GitHub Desktop.
Patch to mylvmbackup send tar+compressed files to remote server via SSH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- /usr/bin/mylvmbackup 2014-02-22 21:09:48.000000000 +0000 | |
+++ /home/jtinley/mylvmbackup 2015-02-06 04:50:30.000000000 +0000 | |
@@ -106,6 +106,7 @@ | |
my $use_thin_snapshots; | |
my $zbackup; | |
my $zbackuparg; | |
+my ($ssh,$ssharg,$sshuser,$sshhost); | |
# Load defaults into variables | |
load_defaults(); | |
@@ -409,6 +410,10 @@ | |
$keep_mount=$cfg->val ('misc', 'keep_mount', $keep_mount); | |
$quiet=$cfg->val ('misc', 'quiet', $quiet); | |
$use_thin_snapshots=$cfg->val ('misc', 'thin', $use_thin_snapshots); | |
+ $ssh = $cfg->val ('misc', 'ssh', $ssh); | |
+ $ssharg = $cfg->val ('misc', 'ssharg', $ssharg); | |
+ $sshuser = $cfg->val ('misc', 'sshuser', $sshuser); | |
+ $sshhost = $cfg->val ('misc', 'sshhost', $sshhost); | |
$mountdir=$cfg->val ('fs', 'mountdir', $mountdir); | |
$backupdir=$cfg->val ('fs', 'backupdir', $backupdir); | |
@@ -437,7 +442,6 @@ | |
$zbackup= $cfg->val ('zbackup', 'zbackup', $zbackup); | |
$zbackuparg= $cfg->val ('zbackup', 'zbackuparg', $zbackuparg); | |
- | |
} | |
# Please keep all 3 functions in the same order: load_config, load_args, load_defaults | |
@@ -493,6 +497,10 @@ | |
"keep_mount" => \&keep_mount, | |
"thin" => \&use_thin_snapshots, | |
"quiet" => \&quiet, | |
+ "ssh=s" => \$ssh, | |
+ "ssharg=s" => \$ssharg, | |
+ "sshuser=s" => \$sshuser, | |
+ "sshhost=s" => \$sshhost, | |
# fs | |
"mountdir=s" => \$mountdir, | |
@@ -572,6 +580,10 @@ | |
$quiet=0; | |
$use_thin_snapshots=0; | |
$errorstate=0; | |
+ $ssh='no'; | |
+ $ssharg=''; | |
+ $sshuser=''; | |
+ $sshhost=''; | |
# fs | |
$mountdir='/var/tmp/mylvmbackup/mnt/'; | |
@@ -693,7 +705,11 @@ | |
$command .= " " . File::Basename::basename($cnfdir) if ($skip_mycnf==0); | |
# If the stuff should be compressed (ie. a compress program has been set), | |
# then the stream has to be piped to the $compress program. | |
- $command .= "| $compress $compressarg -> $tarballtmp" unless ($compress eq ""); | |
+ if ($ssh) { | |
+ $command .= "| $compress $compressarg - | ssh $ssharg $sshuser\@$sshhost \"cat > $tarball\"" unless ($compress eq ""); | |
+ } else { | |
+ $command .= "| $compress $compressarg -> $tarballtmp" unless ($compress eq ""); | |
+ } | |
if (run_command("create tar archive", $command)) | |
{ | |
rename $tarballtmp, $tarball; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is completely untested for any other compatibility, ie if compress is empty, or ssh is not provided.