Skip to content

Instantly share code, notes, and snippets.

@MartinMystikJonas
Created June 2, 2019 12:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save MartinMystikJonas/3066678db837828e98f9071f2f9a14af to your computer and use it in GitHub Desktop.
Save MartinMystikJonas/3066678db837828e98f9071f2f9a14af to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
use strict;
my $remote = 'carol@office.growjob.com::carol/dump';
my $phase = shift;
if ($phase eq 'backup-end') {
my $mode = shift;
my $vmid = shift;
my $vmtype = $ENV{VMTYPE};
my $tarfile = $ENV{TARFILE};
my $ext = ($vmtype eq "qemu") ? "vma.gz" : "tar.gz";
my $remotefile = "$remote/vzdump-$vmtype-$vmid-mirror.$ext";
print "MIRROR BACKUP HOOK: $tarfile -> $remotefile\n";
if ($phase eq 'backup-end') {
my $command = "rsync -h --password-file=/etc/backup_rsync_password --compress-level=6 --stats --partial-dir=.rsync-partial --backup --suffix=.prev $tarfile $remotefile\n";
print $command;
system ($command) == 0 || system ($command) == 0 || die "rsync to backup mirror failed";
}
}
exit (0);
bwlimit: 40960
ionice: 8
pigz: 3
script: /etc/vzdump-hook-script.pl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment