btrbk: use snapshot_dir from config instead of -s option

pull/30/head
Axel Burri 2015-01-13 12:50:21 +01:00
parent 973cebb1c7
commit cc5fa73cf3
1 changed files with 17 additions and 17 deletions

14
btrbk
View File

@ -53,7 +53,6 @@ our $PROJECT_HOME = '<http://www.digint.ch/btrbk>';
my $version_info = "btrbk command line client, version $VERSION"; my $version_info = "btrbk command line client, version $VERSION";
my $default_config = "/etc/btrbk.conf"; my $default_config = "/etc/btrbk.conf";
my $default_snapdir = "_btrbk_snap";
my %vol_info; my %vol_info;
my %uuid_info; my %uuid_info;
@ -65,7 +64,7 @@ my %day_of_week_map = ( monday => 1, tuesday => 2, wednesday => 3, thursday => 4
my %config_options = ( my %config_options = (
# NOTE: the parser always maps "no" to undef # NOTE: the parser always maps "no" to undef
snapshot_dir => { default => "_btrbk_snap", accept_file => "relative" }, snapshot_dir => { default => "_btrbk_snapshot", accept_file => "relative", trailing_slash => 1 },
receive_log => { default => undef, accept => [ "sidecar", "no" ], accept_file => "absolute" }, receive_log => { default => undef, accept => [ "sidecar", "no" ], accept_file => "absolute" },
incremental => { default => "yes", accept => [ "yes", "no", "strict" ] }, incremental => { default => "yes", accept => [ "yes", "no", "strict" ] },
snapshot_create_always => { default => undef, accept => [ "yes", "no" ] }, snapshot_create_always => { default => undef, accept => [ "yes", "no" ] },
@ -93,7 +92,6 @@ sub HELP_MESSAGE
print STDERR "options:\n"; print STDERR "options:\n";
print STDERR " --help display this help message\n"; print STDERR " --help display this help message\n";
print STDERR " --version display version information\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 " -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 " -v be verbose (set loglevel=info)\n";
print STDERR " -l LEVEL set loglevel (1=warn, 2=info, 3=debug, 4=trace)\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"; TRACE "option \"$key=$value\" is a file, accepted";
$value =~ s/\/+$//; # remove trailing slash $value =~ s/\/+$//; # remove trailing slash
$value =~ s/^\/+/\//; # sanitize leading 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 else
{ {
@ -776,10 +778,6 @@ MAIN:
$loglevel = $opts{v} ? 2 : 0; $loglevel = $opts{v} ? 2 : 0;
} }
my $config_file = $opts{c} || $default_config; 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 # check command line options
if($opts{h} || (not $command)) { if($opts{h} || (not $command)) {
@ -1006,6 +1004,7 @@ MAIN:
{ {
next if($config_subvol->{ABORTED}); next if($config_subvol->{ABORTED});
my $svol = $config_subvol->{svol} || die; my $svol = $config_subvol->{svol} || die;
my $snapdir = config_key($config_subvol, "snapshot_dir") || die;
my $snapshot; my $snapshot;
my $snapshot_name; my $snapshot_name;
if($snapshot_cache{"$sroot/$svol"}) if($snapshot_cache{"$sroot/$svol"})
@ -1157,6 +1156,7 @@ MAIN:
{ {
next if($config_subvol->{ABORTED}); next if($config_subvol->{ABORTED});
my $svol = $config_subvol->{svol} || die; my $svol = $config_subvol->{svol} || die;
my $snapdir = config_key($config_subvol, "snapshot_dir") || die;
INFO "Cleaning subvolume backups for: $sroot/$svol"; INFO "Cleaning subvolume backups for: $sroot/$svol";
foreach my $config_target (@{$config_subvol->{TARGET}}) foreach my $config_target (@{$config_subvol->{TARGET}})
{ {