← Back to team overview

mylvmbackup-discuss team mailing list archive

Re: precleanup problem


The precleanup hook was accidentally included in the .12 release. That script was part of a large patch I contributed to allow perl modules to be used as hook scripts. Our use of the script is to purge out old backups older than "rsnapargs" number if days.

I apologize if you suffered data loss. Here at The Planet, Northstar Managed Hosting, we use mylvmbackup on all our customer boxes and have not yet once experienced any data loss.

I'm sure Lenz has removed the script from trunk already.

Sent from my iPhone

On Aug 24, 2009, at 10:26 AM, "Kjetil Torgrim Homme" <kjetil.homme@xxxxxxxxxxxxxxxxxx > wrote:

On Mon, 2009-08-24 at 17:43 +0400, Kirill Morozov wrote:
i have a big problem.
Second time at this week mylvmbackup hook "precleanup" has removed all
content of the server.


This is what i see on screen:
20090824 12:28:55 Info: DONE: create tar archive
20090824 12:28:55 Info: Running hook 'precleanup' as perl module.

/bin/rm: cannot remove directory `//usr/home': Device or resource busy


My /etc/mylvmbackup.conf is:
# File system specific options

relpath should be relative, i.e. "lib/mysql", although it doesn't look
like mylvmbackup itself cares about the distinction, and it's probably
not relevant for your problem.

I think the problem is in the precleanup hook perl package:
       while($_ = readdir(DIR))
               next if /^\.{1,2}$/;
               my $path = "$dest/$_";

               if(-d $path && int(-M $path) > $retention)
                       if(system("/bin/rm -rf $path") != 0)
$errstr .= "Unable to prune $path: $! \n";
       closedir DIR;

Why this hook tries to remove all content of the backup folder
"backupdir=/backup/"? I save another backups in the /backup directory,
not only mylvmbackup, i don't need to remove it.

you're supposed to specify a mylvmbackup specific directory for the
backup.  the default is "/var/tmp/mylvmbackup/backup".

I don't have the precleanup hook script here (what's its source?), but
that is definitely dangerous code. if $path contains spaces, the shell
will split the argument.  e.g., "/backups/my . files/" will try to
delete "backups/my" which doesn't exist, then "." (current directory,
which is probably "/"). shouldn't be a problem for most people, but it
sure would be better to be paranoid about an "rm -rf" command run as
root.  the patch is simple:

-                       if(system("/bin/rm -rf $path") != 0)
+                       if(system("/bin/rm", "-rf", $path) != 0)

Kjetil T. Homme
Redpill Linpro AS - Changing the game

Mailing list: https://launchpad.net/~mylvmbackup-discuss
Post to     : mylvmbackup-discuss@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~mylvmbackup-discuss
More help   : https://help.launchpad.net/ListHelp

Follow ups