From 8cc8a9d5742a42eb74dd54182a8526c31df42c42 Mon Sep 17 00:00:00 2001 From: dpavlin Date: Tue, 7 Feb 2006 21:22:29 +0000 Subject: [PATCH] start of script for disaster recovery: it will re-create BackupPC pool from increments only git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@333 8392b6e1-25fa-0310-8288-cc32f8e212ea --- bin/BackupPC_recover_from_increments | 63 ++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 bin/BackupPC_recover_from_increments diff --git a/bin/BackupPC_recover_from_increments b/bin/BackupPC_recover_from_increments new file mode 100755 index 0000000..867934c --- /dev/null +++ b/bin/BackupPC_recover_from_increments @@ -0,0 +1,63 @@ +#!/usr/bin/perl -w + +# quick hack to create BackupPC pool out of increments + +# 2006-02-07 Dobrica Pavlinusic + +use File::Find; +use Data::Dumper; + +use lib "/data/backuppc/lib"; +use BackupPC::Lib; + + +my $restore_path = './temp/restore.tar.gz'; + +# connect to BackupPC_server + +die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) ); +my %Conf = $bpc->Conf(); + +$bpc->ChildInit(); + +my $err = $bpc->ServerConnect($Conf{ServerHost}, $Conf{ServerPort}); +if ( $err ) { + print("Can't connect to server ($err)\n"); + exit(1); +} + +sub increment { + my $path = $File::Find::name; + + print "working on $path\n"; + + if (-e $restore_path) { + unlink $restore_path || die "can't remove $restore_path: $!\n"; + } + link $path, $restore_path || die "can't create link $path -> $restore_path: $!\n"; + + $bpc->ServerMesg("log User backuppc started restore of $restore_path"); + + my $full = 0; + my $r = $bpc->ServerMesg("backup restore restore backuppc $full"); + print "backup --> $r\n"; + + # Status_backup_in_progress + # Status_idle + + my $state = 'unknown'; + + while ($state ne 'Status_idle') { + my $s = $bpc->ServerMesg("status hosts"); + my %Status; + { + eval "$s"; + } + $state = $Status{restore}->{state}; + print "# $state\n"; #, Dumper($Status{restore}); + sleep 1; + } +} + +find({ wanted => \&increment, follow => 0 }, './temp'); + -- 2.20.1