btrbk: added option -p (preserve backups)

pull/30/head
Axel Burri 2015-02-28 12:02:28 +01:00
parent 02f254bdb3
commit 056f6f9120
2 changed files with 75 additions and 62 deletions

8
btrbk
View File

@ -108,6 +108,7 @@ sub HELP_MESSAGE
print STDERR " --help display this help message\n";
print STDERR " --version display version information\n";
print STDERR " -c FILE specify configuration file\n";
print STDERR " -p preserve all backups (do not delete any old targets)\n";
print STDERR " -v be verbose (set loglevel=info)\n";
print STDERR " -q be quiet (do not print summary at end of \"run\" command)\n";
print STDERR " -l LEVEL set loglevel (warn, info, debug, trace)\n";
@ -960,6 +961,7 @@ MAIN:
}
@config_src = ( $opts{c} ) if($opts{c});
my $quiet = $opts{q};
my $preserve_backups = $opts{p};
# check command line options
if($opts{h} || (not $command)) {
@ -1439,6 +1441,11 @@ MAIN:
#
# remove backups following a preserve daily/weekly/monthly scheme
#
if($preserve_backups) {
INFO "Preserving all backups (option \"-p\" present)";
}
else
{
foreach my $config_vol (@{$config->{VOLUME}})
{
next if($config_vol->{ABORTED});
@ -1520,6 +1527,7 @@ MAIN:
$config_subvol->{schedule} = \@schedule;
}
}
}
my $time_elapsed = time - $start_time;
INFO "Completed within: ${time_elapsed}s (" . localtime(time) . ")";

View File

@ -2,7 +2,7 @@
.SH NAME
btrbk \- backup tool for btrfs volumes
.SH SYNOPSIS
\fBbtrbk\fR [\-\-version] [\-\-help] [\-c <file>] [\-v] [\-q] [\-l <level>] <command> [<args>]
\fBbtrbk\fR [\-\-version] [\-\-help] [\-c <file>] [\-p] [\-v] [\-q] [\-l <level>] <command> [<args>]
.SH DESCRIPTION
\fBbtrbk\fR is a backup tool for btrfs subvolumes, taking advantage of
btrfs specific capabilities to create atomic snapshots and transfer
@ -27,6 +27,10 @@ Prints the synopsis and a list of the commands.
\-c <file>
Read the configuration from <file>.
.TP
\-p
Preserve all backups. Skips deletion of old backups, even if specified
in the configuration file.
.TP
\-v
Verbose output. Identical to: \-l info.
.TP
@ -57,7 +61,8 @@ found. If no common parent subvolume is found, a full backup is
created.
.PP
In a last step, previous snapshots and backup subvolumes that are not
preserved by the current retention policy will be deleted.
preserved by the current retention policy will be deleted. This step
will be skipped if the -p (preserve backups) option is present.
.RE
.PP
.B dryrun