btrbk: added configuration option "ssh_port"

pull/44/head
Axel Burri 2015-08-13 21:39:07 +02:00
parent fd94bc25fc
commit d09d81fbeb
4 changed files with 16 additions and 3 deletions

View File

@ -1,3 +1,7 @@
btrbk-current
* Added configuration option "ssh_port" (close: #39).
btrbk-0.19.3 btrbk-0.19.3
* Bugfix: fix sorting of dates in schedule(). * Bugfix: fix sorting of dates in schedule().

10
btrbk
View File

@ -75,6 +75,7 @@ my %config_options = (
btrfs_commit_delete => { default => undef, accept => [ "after", "each", "no" ] }, btrfs_commit_delete => { default => undef, accept => [ "after", "each", "no" ] },
ssh_identity => { default => undef, accept_file => { absolute => 1 } }, ssh_identity => { default => undef, accept_file => { absolute => 1 } },
ssh_user => { default => "root", accept_regexp => qr/^[a-z_][a-z0-9_-]*$/ }, ssh_user => { default => "root", accept_regexp => qr/^[a-z_][a-z0-9_-]*$/ },
ssh_port => { default => "default", accept => [ "default" ], accept_numeric => 1 },
btrfs_progs_compat => { default => undef, accept => [ "yes", "no" ] }, btrfs_progs_compat => { default => undef, accept => [ "yes", "no" ] },
# deprecated options # deprecated options
@ -226,13 +227,14 @@ sub vinfo($$)
if($url =~ /^ssh:\/\/(\S+?)(\/\S+)$/) { if($url =~ /^ssh:\/\/(\S+?)(\/\S+)$/) {
my ($host, $path) = ($1, $2); my ($host, $path) = ($1, $2);
my $ssh_port = config_key($config, "ssh_port");
my $ssh_user = config_key($config, "ssh_user"); my $ssh_user = config_key($config, "ssh_user");
my $ssh_identity = config_key($config, "ssh_identity"); my $ssh_identity = config_key($config, "ssh_identity");
my @ssh_options; my @ssh_options;
push(@ssh_options, '-p', $ssh_port) if($ssh_port ne "default");
if($ssh_identity) { if($ssh_identity) {
@ssh_options = ('-i', $ssh_identity); push(@ssh_options, '-i', $ssh_identity);
} } else {
else {
WARN "No SSH identity provided (option ssh_identity is not set) for: $url"; WARN "No SSH identity provided (option ssh_identity is not set) for: $url";
} }
%info = ( %info = (
@ -243,6 +245,7 @@ sub vinfo($$)
RSH_TYPE => "ssh", RSH_TYPE => "ssh",
SSH_USER => $ssh_user, SSH_USER => $ssh_user,
SSH_IDENTITY => $ssh_identity, SSH_IDENTITY => $ssh_identity,
SSH_PORT => $ssh_port,
RSH => ['/usr/bin/ssh', @ssh_options, $ssh_user . '@' . $host ], RSH => ['/usr/bin/ssh', @ssh_options, $ssh_user . '@' . $host ],
); );
} }
@ -283,6 +286,7 @@ sub vinfo_child($$)
RSH_TYPE RSH_TYPE
SSH_USER SSH_USER
SSH_IDENTITY SSH_IDENTITY
SSH_PORT
RSH RSH
BTRFS_PROGS_COMPAT ) ) BTRFS_PROGS_COMPAT ) )
{ {

View File

@ -51,6 +51,7 @@ snapshot_dir _btrbk_snap
# Specify SSH private key for "ssh://" volumes / targets: # Specify SSH private key for "ssh://" volumes / targets:
#ssh_identity /etc/btrbk/ssh/id_ed25519 #ssh_identity /etc/btrbk/ssh/id_ed25519
#ssh_user root #ssh_user root
#ssh_port default
# Don't wait for transaction commit on deletion. Set this to "after" # Don't wait for transaction commit on deletion. Set this to "after"
# or "each" to make sure the deletion of subvolumes is committed to # or "each" to make sure the deletion of subvolumes is committed to

View File

@ -116,6 +116,10 @@ Remote username for ssh. Defaults to \[lq]root\[rq]. Note that you will
have to make sure that the remote user is able to run /sbin/btrfs have to make sure that the remote user is able to run /sbin/btrfs
(which needs root privileges). (which needs root privileges).
.TP .TP
\fBssh_port\fR <port>
Port to connect to on the remote host. Defaults to \[lq]default\[rq]
(the port specified in \fIssh_config\fR, which defaults to 22).
.TP
\fBbtrfs_commit_delete\fR after|each|no \fBbtrfs_commit_delete\fR after|each|no
If set, make sure the deletion of snapshot and backup subvolumes are If set, make sure the deletion of snapshot and backup subvolumes are
committed to disk when btrbk terminates. Defaults to \[lq]no\[rq]. committed to disk when btrbk terminates. Defaults to \[lq]no\[rq].