mirror of https://github.com/digint/btrbk
btrbk: use snapshot_dir from config instead of -s option
parent
973cebb1c7
commit
cc5fa73cf3
34
btrbk
34
btrbk
|
@ -53,7 +53,6 @@ our $PROJECT_HOME = '<http://www.digint.ch/btrbk>';
|
|||
my $version_info = "btrbk command line client, version $VERSION";
|
||||
|
||||
my $default_config = "/etc/btrbk.conf";
|
||||
my $default_snapdir = "_btrbk_snap";
|
||||
|
||||
my %vol_info;
|
||||
my %uuid_info;
|
||||
|
@ -65,17 +64,17 @@ my %day_of_week_map = ( monday => 1, tuesday => 2, wednesday => 3, thursday => 4
|
|||
|
||||
my %config_options = (
|
||||
# NOTE: the parser always maps "no" to undef
|
||||
snapshot_dir => { default => "_btrbk_snap", accept_file => "relative" },
|
||||
receive_log => { default => undef, accept => [ "sidecar", "no" ], accept_file => "absolute" },
|
||||
incremental => { default => "yes", accept => [ "yes", "no", "strict" ] },
|
||||
snapshot_create_always => { default => undef, accept => [ "yes", "no" ] },
|
||||
preserve_day_of_week => { default => "sunday", accept => [ (keys %day_of_week_map) ] },
|
||||
snapshot_preserve_daily => { default => "all", accept => [ "all" ], accept_numeric => 1 },
|
||||
snapshot_preserve_weekly => { default => 0, accept => [ "all" ], accept_numeric => 1 },
|
||||
snapshot_preserve_monthly => { default => "all", accept => [ "all" ], accept_numeric => 1 },
|
||||
target_preserve_daily => { default => "all", accept => [ "all" ], accept_numeric => 1 },
|
||||
target_preserve_weekly => { default => 0, accept => [ "all" ], accept_numeric => 1 },
|
||||
target_preserve_monthly => { default => "all", accept => [ "all" ], accept_numeric => 1 },
|
||||
snapshot_dir => { default => "_btrbk_snapshot", accept_file => "relative", trailing_slash => 1 },
|
||||
receive_log => { default => undef, accept => [ "sidecar", "no" ], accept_file => "absolute" },
|
||||
incremental => { default => "yes", accept => [ "yes", "no", "strict" ] },
|
||||
snapshot_create_always => { default => undef, accept => [ "yes", "no" ] },
|
||||
preserve_day_of_week => { default => "sunday", accept => [ (keys %day_of_week_map) ] },
|
||||
snapshot_preserve_daily => { default => "all", accept => [ "all" ], accept_numeric => 1 },
|
||||
snapshot_preserve_weekly => { default => 0, accept => [ "all" ], accept_numeric => 1 },
|
||||
snapshot_preserve_monthly => { default => "all", accept => [ "all" ], accept_numeric => 1 },
|
||||
target_preserve_daily => { default => "all", accept => [ "all" ], accept_numeric => 1 },
|
||||
target_preserve_weekly => { default => 0, accept => [ "all" ], accept_numeric => 1 },
|
||||
target_preserve_monthly => { default => "all", accept => [ "all" ], accept_numeric => 1 },
|
||||
);
|
||||
|
||||
my @config_target_types = qw(send-receive);
|
||||
|
@ -93,7 +92,6 @@ sub HELP_MESSAGE
|
|||
print STDERR "options:\n";
|
||||
print STDERR " --help display this help message\n";
|
||||
print STDERR " --version display version information\n";
|
||||
print STDERR " -s DIR make new source snapshots in subfolder <DIR> (defaults to \"$default_snapdir\")\n";
|
||||
print STDERR " -c FILE config file to be processed on execute command (defaults to \"$default_config\")\n";
|
||||
print STDERR " -v be verbose (set loglevel=info)\n";
|
||||
print STDERR " -l LEVEL set loglevel (1=warn, 2=info, 3=debug, 4=trace)\n";
|
||||
|
@ -342,6 +340,10 @@ sub parse_config($)
|
|||
TRACE "option \"$key=$value\" is a file, accepted";
|
||||
$value =~ s/\/+$//; # remove trailing slash
|
||||
$value =~ s/^\/+/\//; # sanitize leading slash
|
||||
if($config_options{$key}->{trailing_slash}) {
|
||||
TRACE "trailing_slash is specified for option \"$key\", adding trailing slash";
|
||||
$value .= '/';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -776,10 +778,6 @@ MAIN:
|
|||
$loglevel = $opts{v} ? 2 : 0;
|
||||
}
|
||||
my $config_file = $opts{c} || $default_config;
|
||||
my $snapdir = $opts{s} || $default_snapdir;
|
||||
$snapdir =~ s/\/+$//; # remove trailing slash
|
||||
$snapdir =~ s/^\/+//; # remove leading slash
|
||||
$snapdir .= '/'; # add trailing slash
|
||||
|
||||
# check command line options
|
||||
if($opts{h} || (not $command)) {
|
||||
|
@ -1006,6 +1004,7 @@ MAIN:
|
|||
{
|
||||
next if($config_subvol->{ABORTED});
|
||||
my $svol = $config_subvol->{svol} || die;
|
||||
my $snapdir = config_key($config_subvol, "snapshot_dir") || die;
|
||||
my $snapshot;
|
||||
my $snapshot_name;
|
||||
if($snapshot_cache{"$sroot/$svol"})
|
||||
|
@ -1157,6 +1156,7 @@ MAIN:
|
|||
{
|
||||
next if($config_subvol->{ABORTED});
|
||||
my $svol = $config_subvol->{svol} || die;
|
||||
my $snapdir = config_key($config_subvol, "snapshot_dir") || die;
|
||||
INFO "Cleaning subvolume backups for: $sroot/$svol";
|
||||
foreach my $config_target (@{$config_subvol->{TARGET}})
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue