btrbk/documentation: rename "resolve *" commands to "list *"; cleanup

pull/57/head
Axel Burri 2015-10-22 17:45:27 +02:00
parent 288e9e73c8
commit 3f09d2c37f
7 changed files with 97 additions and 100 deletions

View File

@ -1,9 +1,11 @@
btrbk-current btrbk-current
* Added transaction log (configuration option "transaction_log").
* Added configuration option "group". * Added configuration option "group".
* Allow filtering subcommands by group as well as targets. * Allow filtering of all commands by group as well as targets.
* Added "list backups|snapshots|latest|config|source|volume|target"
commands (while removing "tree" command).
* Added "config print" command. * Added "config print" command.
* Added "list" command (experimental).
* Added "--format=table|long|raw" and "-t,--table" command line * Added "--format=table|long|raw" and "-t,--table" command line
options, producing tabular and raw (machine-readable) output for options, producing tabular and raw (machine-readable) output for
"(dry)run", "tree" and "list" commands. "(dry)run", "tree" and "list" commands.
@ -12,7 +14,6 @@ btrbk-current
* Added "target raw", with GnuPG and compression support * Added "target raw", with GnuPG and compression support
(experimental). (experimental).
* Added configuration option "timestamp_format short|long". * Added configuration option "timestamp_format short|long".
* Added transaction log (configuration option "transaction_log").
* Replaced "info" command with "usage", with tabular output. * Replaced "info" command with "usage", with tabular output.
* Bugfix: correctly handle "incremental no" option. * Bugfix: correctly handle "incremental no" option.
* Bugfix: return exit status 10 instead of 0 if one or more backup * Bugfix: return exit status 10 instead of 0 if one or more backup

View File

@ -364,7 +364,7 @@ Example: Restore a Snapshot
First, pick a snapshot to be restored: First, pick a snapshot to be restored:
btrbk tree btrbk list snapshots
From the list, pick the snapshot you want to restore. Let's say it's From the list, pick the snapshot you want to restore. Let's say it's
`/mnt/btr_pool/_btrbk_snap/data.20150101`. `/mnt/btr_pool/_btrbk_snap/data.20150101`.
@ -388,7 +388,7 @@ Example: Restore a Backup
First, pick a backup to be restored: First, pick a backup to be restored:
btrbk tree btrbk list backups
From the list, pick the backup you want to restore. Let's say it's From the list, pick the backup you want to restore. Let's say it's
`/mnt/btr_backup/data.20150101`. `/mnt/btr_backup/data.20150101`.

108
btrbk
View File

@ -120,8 +120,8 @@ my %config_options = (
my @config_target_types = qw(send-receive raw); my @config_target_types = qw(send-receive raw);
my %table_formats = ( my %table_formats = (
list_volume => { table => [ qw( volume_host volume_subvol ) ], list_volume => { table => [ qw( volume_host volume_path ) ],
long => [ qw( volume_host volume_subvol ) ], long => [ qw( volume_host volume_path ) ],
raw => [ qw( volume_url volume_host volume_path volume_rsh ) ], raw => [ qw( volume_url volume_host volume_path volume_rsh ) ],
}, },
list_source => { table => [ qw( source_host source_subvol snapshot_path snapshot_name ) ], list_source => { table => [ qw( source_host source_subvol snapshot_path snapshot_name ) ],
@ -196,7 +196,7 @@ sub VERSION_MESSAGE
sub HELP_MESSAGE sub HELP_MESSAGE
{ {
print STDERR "usage: btrbk [options] <command>\n"; print STDERR "usage: btrbk [options] <command> [filter...]\n";
print STDERR "\n"; print STDERR "\n";
print STDERR "options:\n"; print STDERR "options:\n";
# "--------------------------------------------------------------------------------"; # 80 # "--------------------------------------------------------------------------------"; # 80
@ -214,19 +214,24 @@ sub HELP_MESSAGE
print STDERR " --progress show progress bar on send-receive operation\n"; print STDERR " --progress show progress bar on send-receive operation\n";
print STDERR "\n"; print STDERR "\n";
print STDERR "commands:\n"; print STDERR "commands:\n";
print STDERR " run [filter...] perform backup operations as defined in the config file\n"; print STDERR " run perform backup operations as defined in the config file\n";
print STDERR " dryrun [filter...] don't run btrfs commands; show what would be executed\n"; print STDERR " dryrun don't run btrfs commands; show what would be executed\n";
print STDERR " list [filter...] print source/snapshot/target relations\n"; print STDERR " list <subcommand> available subcommands are:\n";
print STDERR " resolve snapshots [filter...] shows snapshots and corresponding targets\n"; print STDERR " backups all backups and corresponding snapshots\n";
print STDERR " resolve targets [filter...] shows targets and corresponding snapshots\n"; print STDERR " snapshots all snapshots and corresponding backups\n";
print STDERR " resolve latest [filter...] shows latest snapshots/targets\n"; print STDERR " latest most recent snapshots and backups\n";
print STDERR " usage [filter...] print filesystem usage\n"; print STDERR " config configured source/snapshot/target relations\n";
print STDERR " source configured source/snapshot relations\n";
print STDERR " volume configured volume sections\n";
print STDERR " target configured targets\n";
print STDERR " usage print filesystem usage\n";
print STDERR " origin <subvol> print origin information for subvolume\n"; print STDERR " origin <subvol> print origin information for subvolume\n";
print STDERR " diff <from> <to> shows new files since subvolume <from> for subvolume <to>\n"; print STDERR " diff <from> <to> shows new files since subvolume <from> for subvolume <to>\n";
print STDERR "\n"; print STDERR "\n";
print STDERR "For additional information, see $PROJECT_HOME\n"; print STDERR "For additional information, see $PROJECT_HOME\n";
} }
sub TRACE { my $t = shift; print STDERR "... $t\n" if($loglevel >= 4); } sub TRACE { my $t = shift; print STDERR "... $t\n" if($loglevel >= 4); }
sub DEBUG { my $t = shift; print STDERR "$t\n" if($loglevel >= 3); } sub DEBUG { my $t = shift; print STDERR "$t\n" if($loglevel >= 3); }
sub INFO { my $t = shift; print STDERR "$t\n" if($loglevel >= 2); } sub INFO { my $t = shift; print STDERR "$t\n" if($loglevel >= 2); }
@ -2136,89 +2141,60 @@ MAIN:
} }
my ($action_run, $action_usage, $action_resolve, $action_diff, $action_origin, $action_config_print, $action_list); my ($action_run, $action_usage, $action_resolve, $action_diff, $action_origin, $action_config_print, $action_list);
my @filter_args; my @filter_args;
my $args_allow_group = 0; my $args_allow_group = 1;
my ($args_expected_min, $args_expected_max) = (0, 0); my $args_expected_min = 0;
my $args_expected_max = 9999;
if(($command eq "run") || ($command eq "dryrun")) { if(($command eq "run") || ($command eq "dryrun")) {
$action_run = 1; $action_run = 1;
$dryrun = 1 if($command eq "dryrun"); $dryrun = 1 if($command eq "dryrun");
$args_expected_min = 0;
$args_expected_max = 9999;
$args_allow_group = 1; $args_allow_group = 1;
@filter_args = @ARGV; @filter_args = @ARGV;
} }
elsif ($command eq "usage") { elsif ($command eq "usage") {
$action_usage = 1; $action_usage = 1;
$args_expected_min = 0;
$args_expected_max = 9999;
$args_allow_group = 1;
@filter_args = @ARGV; @filter_args = @ARGV;
} }
elsif ($command eq "resolve") {
my $subcommand = shift @ARGV // "";
if($subcommand eq "snapshots") {
$action_resolve = $subcommand;
$args_expected_min = 0;
$args_expected_max = 9999;
$args_allow_group = 1;
@filter_args = @ARGV;
}
elsif($subcommand eq "latest") {
$action_resolve = $subcommand;
$args_expected_min = 0;
$args_expected_max = 9999;
$args_allow_group = 1;
@filter_args = @ARGV;
}
elsif($subcommand eq "targets") {
$action_resolve = $subcommand;
$args_expected_min = 0;
$args_expected_max = 9999;
$args_allow_group = 1;
@filter_args = @ARGV;
}
else {
ERROR "Unknown subcommand for \"resolve\" command: $subcommand";
HELP_MESSAGE(0);
exit 2;
}
}
elsif ($command eq "diff") { elsif ($command eq "diff") {
$action_diff = 1; $action_diff = 1;
$args_expected_min = $args_expected_max = 2; $args_expected_min = $args_expected_max = 2;
$args_allow_group = 0;
@filter_args = @ARGV; @filter_args = @ARGV;
} }
elsif ($command eq "origin") { elsif ($command eq "origin") {
$action_origin = 1; $action_origin = 1;
$args_expected_min = $args_expected_max = 1; $args_expected_min = $args_expected_max = 1;
$args_allow_group = 0;
@filter_args = @ARGV; @filter_args = @ARGV;
} }
elsif($command eq "list") { elsif($command eq "list") {
my $subcommand = shift @ARGV; my $subcommand = shift @ARGV // "";
$action_list = "target-all"; if(($subcommand eq "config") ||
if(defined($subcommand)) { ($subcommand eq "volume") ||
if(($subcommand eq "volume") || ($subcommand eq "source") ||
($subcommand eq "source") || ($subcommand eq "target"))
($subcommand eq "target")) {
{ $action_list = $subcommand;
$action_list = $subcommand; }
} elsif(($subcommand eq "snapshots") ||
else { ($subcommand eq "backups") ||
unshift @ARGV, $subcommand; ($subcommand eq "latest"))
} {
$action_resolve = $subcommand;
}
else {
$action_list = "config";
unshift @ARGV, $subcommand if($subcommand ne "");
} }
$args_expected_min = 0;
$args_expected_max = 9999;
$args_allow_group = 1;
@filter_args = @ARGV; @filter_args = @ARGV;
} }
elsif ($command eq "config") { elsif ($command eq "config") {
my $subcommand = shift @ARGV // ""; my $subcommand = shift @ARGV // "";
@filter_args = @ARGV;
if(($subcommand eq "print") || ($subcommand eq "print-all")) { if(($subcommand eq "print") || ($subcommand eq "print-all")) {
$action_config_print = $subcommand; $action_config_print = $subcommand;
$args_expected_min = 0; }
$args_expected_max = 9999; elsif($subcommand eq "list") {
$args_allow_group = 1; $action_list = "config";
@filter_args = @ARGV;
} }
else { else {
ERROR "Unknown subcommand for \"config\" command: $subcommand"; ERROR "Unknown subcommand for \"config\" command: $subcommand";
@ -2864,7 +2840,7 @@ MAIN:
} }
} }
} }
elsif($action_resolve eq "targets") elsif($action_resolve eq "backups")
{ {
# #
# print all targets and their corresponding source snapshots # print all targets and their corresponding source snapshots

View File

@ -9,6 +9,9 @@
# #
# Enable transaction log
transaction_log /var/log/btrbk.log
# Directory in which the btrfs snapshots are created. Relative to # Directory in which the btrfs snapshots are created. Relative to
# <volume-directory> of the volume section. # <volume-directory> of the volume section.
# If not set, the snapshots are created in <volume-directory>. # If not set, the snapshots are created in <volume-directory>.
@ -64,9 +67,6 @@ snapshot_dir _btrbk_snap
# Set this either globally or in a specific "target" section. # Set this either globally or in a specific "target" section.
#btrfs_progs_compat no #btrfs_progs_compat no
# Enable transaction log
#transaction_log /var/log/btrbk_transaction.log
# #
# Volume section: "volume <volume-directory>" # Volume section: "volume <volume-directory>"

View File

@ -37,7 +37,7 @@ valid mount-points, you can loop through the configuration and mount
the volumes like this: the volumes like this:
#!/bin/sh #!/bin/sh
btrbk config list volume --format=raw | while read line; do btrbk list volume --format=raw | while read line; do
eval $line eval $line
$volume_rsh mount $volume_path $volume_rsh mount $volume_path
done done

View File

@ -9,7 +9,9 @@ btrbk \- backup tool for btrfs volumes
.nf .nf
\fBbtrbk\fR [\-h|\-\-help] [\-\-version] [\-c|\-\-config <file>] \fBbtrbk\fR [\-h|\-\-help] [\-\-version] [\-c|\-\-config <file>]
[\-p|\-\-preserve] [\-r|\-\-resume\-only] [\-p|\-\-preserve] [\-r|\-\-resume\-only]
[\-v|\-\-verbose] [\-q|\-\-quiet] [\-l|\-\-loglevel <level>] [\-\-progress] [\-v|\-\-verbose] [\-q|\-\-quiet] [\-l|\-\-loglevel <level>]
[\-t|\-\-table] [\-\-format <output\-format>]
[\-\-progress]
<command> [<args>] <command> [<args>]
.fi .fi
.SH DESCRIPTION .SH DESCRIPTION
@ -64,7 +66,8 @@ set to \[lq]yes\[rq] in the configuration file.
.PP .PP
\-v, \-\-verbose \-v, \-\-verbose
.RS 4 .RS 4
Verbose output. Identical to: \-l info. Verbose output. Sets "\-l info", and prints detailed scheduler
information on "run" and "dryrun" commands.
.RE .RE
.PP .PP
\-q, \-\-quiet \-q, \-\-quiet
@ -142,23 +145,39 @@ would be executed.
.RE .RE
.PP .PP
.B list .B list
[filter...] <subcommand> [filter...]
.RS 4 .RS 4
Print the source/snapshot/target relations of the configured Print information defined by <subcommand> in a tabular form. Optionally
subvolumes in a tabular form. Optionally filtered by [filter...] filtered by [filter...] arguments (see \fIFILTER STATEMENTS\fR
arguments (see \fIFILTER STATEMENTS\fR below). Accepts predefined below).
filters \fIvolume\fR, \fIsource\fR and \fItarget\fR. Use the
\fI\-\-format\fR command line option to switch between different
output formats.
.RE
.PP .PP
.B tree Available subcommands:
[filter...] .TP 11
.RS 4 .B snapshots
Print the snapshots and their corresponding backup subvolumes as a All snapshots (and corresponding backups).
tree. Optionally filtered by [filter...] arguments (see \fIFILTER .PD 0
STATEMENTS\fR below). Use the \fI\-\-format\fR command line option to .TP 11
switch between different output formats. .B backups
All backups (and corresponding snapshots).
.TP 11
.B latest
Most recent snapshots and backups.
.TP 11
.B config
Configured source/snapshot/target relations.
.TP 11
.B source
Configured source/snapshot relations.
.TP 11
.B volume
Configured volume sections.
.TP 11
.B target
Configured targets.
.PD
.PP
Use the \fI\-\-format\fR command line option to switch between
different output formats.
.RE .RE
.PP .PP
.B usage .B usage
@ -193,7 +212,8 @@ Filter arguments are accepted in form:
.PP .PP
[hostname:]<volume-directory> [hostname:]<volume-directory>
.RS 4 .RS 4
Matches all subvolumes and targets of a \fIvolume\fR configuration section. Matches all subvolumes and targets of a \fIvolume\fR configuration
section.
.RE .RE
.PP .PP
[hostname:]<volume-directory>/<subvolume-name> [hostname:]<volume-directory>/<subvolume-name>

View File

@ -105,6 +105,13 @@ be able to delete old backups.
.RE .RE
.SH OPTIONS .SH OPTIONS
.PP .PP
\fBtransaction_log\fR <file>
.RS 4
If set, all transactions (snapshot create, subvolume send-receive,
subvolume delete) as well as abort messages are logged to <file>, in a
space-separated table format.
.RE
.PP
\fBtimestamp_format\fR short|long \fBtimestamp_format\fR short|long
.RS 4 .RS 4
Timestamp format used as postfix for new snapshot subvolume names. Timestamp format used as postfix for new snapshot subvolume names.
@ -258,13 +265,6 @@ can lead to false guesses if the snapshot or target subvolumes are
manipulated by hand (moved, deleted). manipulated by hand (moved, deleted).
.RE .RE
.PP .PP
\fBtransaction_log\fR <file>
.RS 4
If set, all transactions (snapshot create, subvolume send-receive,
subvolume delete) as well as abort messages are logged to <file>, in a
space-separated table format.
.RE
.PP
Lines that contain a hash character (#) in the first column are Lines that contain a hash character (#) in the first column are
treated as comments. treated as comments.
.SH AVAILABILITY .SH AVAILABILITY