From c57e7e51d8701dbe96903b1a0b4838338c522836 Mon Sep 17 00:00:00 2001 From: BartJol Date: Thu, 6 Jan 2011 12:17:48 +0100 Subject: [PATCH 1/7] removing files at low rotations after backup and copytoremote --- wre/sbin/backup.pl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/wre/sbin/backup.pl b/wre/sbin/backup.pl index 3ff30e2..a8de1a3 100755 --- a/wre/sbin/backup.pl +++ b/wre/sbin/backup.pl @@ -40,6 +40,7 @@ runExternalScripts($config); compressBackups($config); copyToRemote($config); +removeBackupFiles($config); #------------------------------------------------------------------- @@ -232,6 +233,24 @@ sub copyToRemote { system($cmd); } +#------------------------------------------------------------------- +sub removeBackupFiles { + my $config = shift; + my $backupDir = dir($config->get("backup/path")); + my $rotations = $config->get("backup/rotations"); + if ($rotations eq "0" ||$rotations eq "1") { + opendir(DIR,$backupDir->stringify); + my @files = readdir(DIR); + closedir(DIR); + foreach my $file (@files) { + if ($rotations eq "0") { + $backupDir->file($file)->remove; + elsif ($file =~ /(.*\.)1/ ) { + $backupDir->file($file)->remove; + } + } + } +} #------------------------------------------------------------------- sub rotateBackupFiles { my $config = shift; From ff3a706280ea716609f1ec05392a098cf424f640 Mon Sep 17 00:00:00 2001 From: BartJol Date: Thu, 6 Jan 2011 13:03:26 +0100 Subject: [PATCH 2/7] fixed syntax error --- wre/sbin/backup.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/wre/sbin/backup.pl b/wre/sbin/backup.pl index a8de1a3..bfda15b 100755 --- a/wre/sbin/backup.pl +++ b/wre/sbin/backup.pl @@ -245,6 +245,7 @@ sub removeBackupFiles { foreach my $file (@files) { if ($rotations eq "0") { $backupDir->file($file)->remove; + } elsif ($file =~ /(.*\.)1/ ) { $backupDir->file($file)->remove; } From 8271ff454d744ddb81ba8ff440dfdd61a2b2542e Mon Sep 17 00:00:00 2001 From: BartJol Date: Fri, 7 Jan 2011 18:02:16 +0100 Subject: [PATCH 3/7] rotation comaprison numerical instead of string --- wre/sbin/backup.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wre/sbin/backup.pl b/wre/sbin/backup.pl index bfda15b..3c23f32 100755 --- a/wre/sbin/backup.pl +++ b/wre/sbin/backup.pl @@ -238,7 +238,7 @@ sub removeBackupFiles { my $config = shift; my $backupDir = dir($config->get("backup/path")); my $rotations = $config->get("backup/rotations"); - if ($rotations eq "0" ||$rotations eq "1") { + if ($rotations == 0 ||$rotations == 1) { opendir(DIR,$backupDir->stringify); my @files = readdir(DIR); closedir(DIR); From 76872f64aef7ff6113cc5b278f75404585ed6a6a Mon Sep 17 00:00:00 2001 From: BartJol Date: Fri, 4 Feb 2011 13:32:40 +0100 Subject: [PATCH 4/7] added customdir backup --- wre/sbin/backup.pl | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/wre/sbin/backup.pl b/wre/sbin/backup.pl index 3c23f32..577c183 100755 --- a/wre/sbin/backup.pl +++ b/wre/sbin/backup.pl @@ -37,11 +37,39 @@ backupDomains($config); backupWebgui($config); backupWre($config); +backupCustom($config); runExternalScripts($config); compressBackups($config); copyToRemote($config); -removeBackupFiles($config); +#removeBackupFiles($config); +#------------------------------------------------------------------- +sub backupCustom { + my $config = shift; + + return undef unless $config->get("backup/items/custom"); + + my $backupDir = dir($config->get("backup/path")); + my $customFile = $config->getWebguiRoot("/sbin/preload.custom"); + open FILE, $customFile or die $!; + my @lines = ; + my @customDirs; + foreach my $line (@lines) { + if ($line =~ /^\//) { + my $backupFile = join("",map { ucfirst($_) } split /\//, $line); + chomp $backupFile; + + eval { $util->tar( + file => $backupDir->file($backupFile.".tar")->stringify, + stuff => [$line], + )}; + print $@."\n" if ($@); + } + else { + next; + } + } +} #------------------------------------------------------------------- sub backupDomains { From 3a9f889c4806d281bc5bc3331113de8a75e8e5ef Mon Sep 17 00:00:00 2001 From: BartJol Date: Fri, 4 Feb 2011 13:33:57 +0100 Subject: [PATCH 5/7] added custom option to wre.conf setupfile --- wre/var/setupfiles/wre.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wre/var/setupfiles/wre.conf b/wre/var/setupfiles/wre.conf index 671a529..deeae6c 100644 --- a/wre/var/setupfiles/wre.conf +++ b/wre/var/setupfiles/wre.conf @@ -95,7 +95,8 @@ "fullWre" : 0, "smallWre" : 1, "domainsFolder" : 1, - "webgui" : 1 + "webgui" : 1, + "custom" : 1, }, "externalScripts" : [], "ftp" : { From 56286153a1c62ebd0a452891d699f5f0ec882740 Mon Sep 17 00:00:00 2001 From: BartJol Date: Fri, 4 Feb 2011 13:35:50 +0100 Subject: [PATCH 6/7] uncommented commented method --- wre/sbin/backup.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wre/sbin/backup.pl b/wre/sbin/backup.pl index 577c183..083f208 100755 --- a/wre/sbin/backup.pl +++ b/wre/sbin/backup.pl @@ -41,7 +41,7 @@ runExternalScripts($config); compressBackups($config); copyToRemote($config); -#removeBackupFiles($config); +removeBackupFiles($config); #------------------------------------------------------------------- sub backupCustom { From cc70f55e0b34028171a350f66c76c7c798c65acf Mon Sep 17 00:00:00 2001 From: BartJol Date: Fri, 4 Feb 2011 13:51:07 +0100 Subject: [PATCH 7/7] supressed leading slash tar warning --- wre/lib/WRE/File.pm | 3 +++ wre/sbin/backup.pl | 1 + 2 files changed, 4 insertions(+) diff --git a/wre/lib/WRE/File.pm b/wre/lib/WRE/File.pm index e468082..9022a16 100644 --- a/wre/lib/WRE/File.pm +++ b/wre/lib/WRE/File.pm @@ -437,6 +437,9 @@ sub tar { if ($options{gzip}) { $args .= " --gzip"; } + if ($options{absPath}) { + $args .= " -P"; + } if (exists $options{exclude}) { my $exFile = file($options{exclude}); if (-e $exFile) { diff --git a/wre/sbin/backup.pl b/wre/sbin/backup.pl index 083f208..4b78625 100755 --- a/wre/sbin/backup.pl +++ b/wre/sbin/backup.pl @@ -62,6 +62,7 @@ sub backupCustom { eval { $util->tar( file => $backupDir->file($backupFile.".tar")->stringify, stuff => [$line], + absPath => 1, )}; print $@."\n" if ($@); }