]> git.pld-linux.org Git - packages/bacula-backup-mysql.git/commitdiff
- add -cleanup support
authorElan Ruusamäe <glen@pld-linux.org>
Tue, 16 Jun 2009 15:06:23 +0000 (15:06 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    bacula-backup-mysql -> 1.5

bacula-backup-mysql

index 46e5ea348d9a6e27c7b33426d0758223835cc06d..b334821a49a5435706ec97723686901b54357b75 100644 (file)
@@ -1,4 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl -ws
+# Rudimentary switch parsing. Must be in main package.
+our $cleanup;
+
 package BBM;
 use strict;
 use POSIX qw(setuid setgid);
@@ -6,6 +9,7 @@ use DBI;
 use File::Temp qw(tempdir);
 use File::Path qw(rmtree);
 
+
 # path to Apache HTTPd-style config
 my $config = '/etc/bacula/backup-mysql.conf';
 my $c = new BBM::Config($config);
@@ -16,6 +20,9 @@ unless ($<) {
        my $gid = getgrnam('mysql');
        die "Can't find user/group mysql\n" unless $uid or $gid;
 
+       # CWD could not be accessible for mysql user
+       chdir("/");
+
        $) = "$gid $gid";
        $( = $gid;
        $> = $< = $uid;
@@ -35,7 +42,11 @@ if (!-d $tmpdir && !mkdir($tmpdir) && !-d $tmpdir) {
 # process each cluster
 for my $cluster ($c->get('clusters', 'cluster')) {
        print ">>> $cluster\n";
-       backup_cluster($cluster);
+       if ($cleanup) {
+               cleanup_cluster($cluster);
+       } else {
+               backup_cluster($cluster);
+       }
        print "<<< $cluster\n";
 }
 
@@ -76,6 +87,14 @@ sub mysqlhotcopy {
        print "<<<< mysqlhotcopy $database\n";
 }
 
+sub cleanup_cluster {
+       my ($cluster) = @_;
+       my $cluster_dir = "$backup_dir/$cluster";
+       print ">>>> cleanup $cluster_dir\n";
+       rmtree($cluster_dir);
+       print "<<<< cleanup $cluster_dir\n";
+}
+
 sub backup_cluster {
        my ($cluster) = @_;
 
This page took 0.097864 seconds and 4 git commands to generate.