From 6a00736a2b101f779bda77db155ce3c892b2ba0c Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Sat, 17 Jan 2015 14:55:46 +0100 Subject: [PATCH] btrbk: added more information on backup summary; added documentation --- btrbk | 35 ++++++++++++++++++++--------------- btrbk.conf.example | 37 +++++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 25 deletions(-) diff --git a/btrbk b/btrbk index e1e574f..1da39fe 100755 --- a/btrbk +++ b/btrbk @@ -279,13 +279,6 @@ sub check_file($$$$) sub parse_config(@) { my @config_files = @_; - my $root = { CONTEXT => "root" }; - my $cur = $root; - # set defaults - foreach (keys %config_options) { - $root->{$_} = $config_options{$_}->{default}; - } - my $file = undef; foreach(@config_files) { TRACE "config: checking for file: $_"; @@ -299,6 +292,13 @@ sub parse_config(@) return undef; } + my $root = { CONTEXT => "root", SRC_FILE => $file }; + my $cur = $root; + # set defaults + foreach (keys %config_options) { + $root->{$_} = $config_options{$_}->{default}; + } + DEBUG "config: parsing file: $file"; open(FILE, '<', $file) or die $!; while () { @@ -866,6 +866,7 @@ MAIN: $ENV{PATH} = ''; $Getopt::Std::STANDARD_HELP_VERSION = 1; $Data::Dumper::Sortkeys = 1; + my $start_time = time; my @today = Today(); my %opts; @@ -1323,6 +1324,8 @@ MAIN: } } + my $time_elapsed = time - $start_time; + INFO "Completed within: ${time_elapsed}s"; # # print summary @@ -1331,7 +1334,9 @@ MAIN: { my $err_count = 0; print "--------------------------------------------------------------------------------\n"; - print "Backup Summary ($version_info)\n"; + print "Backup Summary ($version_info)\n\n"; + print " Date: " . localtime($start_time) . "\n"; + print " Config: $config->{SRC_FILE}\n"; print "--------------------------------------------------------------------------------"; foreach my $config_vol (@{$config->{VOLUME}}) { @@ -1351,10 +1356,10 @@ MAIN: # print(($_->{preserve} ? "===" : "---") . " $_->{name}\n"); # } # } - if($config_subvol->{subvol_deleted}) { - print "--- $_\n" foreach(@{$config_subvol->{subvol_deleted}}); - } print "+++ $config_subvol->{snapshot}\n" if($config_subvol->{snapshot}); + if($config_subvol->{subvol_deleted}) { + print "--- $_\n" foreach(sort { $b cmp $a} @{$config_subvol->{subvol_deleted}}); + } foreach my $config_target (@{$config_subvol->{TARGET}}) { if($config_target->{ABORTED}) { @@ -1366,10 +1371,10 @@ MAIN: # print(($_->{preserve} ? "===" : "---") . " $_->{name}\n"); # } # } - if($config_target->{subvol_deleted}) { - print "--- $_\n" foreach(@{$config_target->{subvol_deleted}}); - } print "+++ $config_target->{subvol_created}\n" if($config_target->{subvol_created}); + if($config_target->{subvol_deleted}) { + print "--- $_\n" foreach(sort { $b cmp $a} @{$config_target->{subvol_deleted}}); + } } } } @@ -1378,7 +1383,7 @@ MAIN: print "Please check warning and error messages above.\n"; } if($dryrun) { - print "\nNOTE: Dryrun was active, none of the operations below were actually executed!\n"; + print "\nNOTE: Dryrun was active, none of the operations above were actually executed!\n"; } } } diff --git a/btrbk.conf.example b/btrbk.conf.example index e643b93..5049c63 100644 --- a/btrbk.conf.example +++ b/btrbk.conf.example @@ -3,15 +3,16 @@ # Create snapshot into subdirectory snapshot_dir _btrbk_snap -# Always create backups, even if the target volume is not reachable +# Always create snapshots, even if the target volume is unreachable snapshot_create_always yes -# Perform incremental backups -incremental strict +# Perform incremental backups (set to "strict" if you want to prevent +# creation of initial backups if no parent is found) +incremental yes # ssh key for ssh volumes/targets ssh_identity /etc/btrbk/ssh/id_ed25519 -ssh_user root +ssh_user root # Preserve weekly/monthly backups from given day of week preserve_day_of_week sunday @@ -29,19 +30,36 @@ target_preserve_monthly all # Make sure the deletion of subvolumes is committed to disk when btrbk terminates btrfs_commit_delete after +# Dump verbose output of "btrfs receive" to a specified file. If set +# to "sidecar", the file will be named ".btrbk.log". +# Note that this log file can become very big, as every change of +# every file is being logged. +#receive_log /var/log/btrbk_receive.log +#receive_log sidecar +receive_log no + +# # Volume section: "volume " # : Directory of a btrfs volume (or subvolume) containing the # subvolume to be backuped (usually the mount-point of a # btrfs filesystem mounted with subvolid=0 option) # # Subvolume section: "subvolume -# : Subvolume to be backuped, relative to in -# volume section +# : Subvolume to be backuped, relative to in +# volume section +# +# Target section: "target " +# : Backup type, currently only "send-receive" +# : Directory of a btrfs volume (or subvolume) receiving the backups +# +# +# NOTE: The parser does not care about indentation, this is only for +# human readability. The options always apply to the last section +# encountered, overriding the corresponding option of the upper +# section. This means that the global options must be set before any +# "volume" section. # -# Target section: "target " -# : Backup type, currently only "send-receive" -# : Directory of a btrfs volume (or subvolume) receiving the backups volume /mnt/btr_system subvolume root_gentoo @@ -58,7 +76,6 @@ volume /mnt/btr_system target_preserve_weekly 0 target send-receive /mnt/btr_backup/_btrbk - receive_log sidecar volume /mnt/btr_data