start of script for disaster recovery: it will re-create BackupPC pool from increment...
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Tue, 7 Feb 2006 21:22:29 +0000 (21:22 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Tue, 7 Feb 2006 21:22:29 +0000 (21:22 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@333 8392b6e1-25fa-0310-8288-cc32f8e212ea

bin/BackupPC_recover_from_increments [new file with mode: 0755]

diff --git a/bin/BackupPC_recover_from_increments b/bin/BackupPC_recover_from_increments
new file mode 100755 (executable)
index 0000000..867934c
--- /dev/null
@@ -0,0 +1,63 @@
+#!/usr/bin/perl -w
+
+# quick hack to create BackupPC pool out of increments
+
+# 2006-02-07 Dobrica Pavlinusic <dpavlin@rot13.org>
+
+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');
+