Implement "synology" compat option for Synology NAS

By default, the Synology DSM "btrfs send" command outputs ACL attributes that are not compatible
with a normal Btrfs implementation. The option compat "synology" allows passing the --without-syno-features
option, which makes "btrfs send" compatible with standard Btrfs implementations.
pull/574/head
Bernhard Kaszt 2023-12-03 11:42:21 +01:00
parent 18ddc65979
commit 4b8794f3ec
4 changed files with 30 additions and 3 deletions

View File

@ -1,3 +1,7 @@
unreleased
* Add "synology" compat option for Synology NAS.
btrbk-0.32.6 btrbk-0.32.6
* Fix backup of unrelated (by parent_uuid) snapshots (close #339). * Fix backup of unrelated (by parent_uuid) snapshots (close #339).

8
btrbk
View File

@ -142,9 +142,9 @@ my %config_options = (
backend_remote => { default => undef, accept => [qw( no btrfs-progs btrfs-progs-btrbk btrfs-progs-sudo btrfs-progs-doas )] }, backend_remote => { default => undef, accept => [qw( no btrfs-progs btrfs-progs-btrbk btrfs-progs-sudo btrfs-progs-doas )] },
backend_local_user => { default => undef, accept => [qw( no btrfs-progs btrfs-progs-btrbk btrfs-progs-sudo btrfs-progs-doas )] }, backend_local_user => { default => undef, accept => [qw( no btrfs-progs btrfs-progs-btrbk btrfs-progs-sudo btrfs-progs-doas )] },
compat => { default => undef, accept => [qw( no busybox ignore_receive_errors )], split => 1 }, compat => { default => undef, accept => [qw( no busybox ignore_receive_errors synology )], split => 1 },
compat_local => { default => undef, accept => [qw( no busybox ignore_receive_errors )], split => 1 }, compat_local => { default => undef, accept => [qw( no busybox ignore_receive_errors synology )], split => 1 },
compat_remote => { default => undef, accept => [qw( no busybox ignore_receive_errors )], split => 1 }, compat_remote => { default => undef, accept => [qw( no busybox ignore_receive_errors synology )], split => 1 },
safe_commands => { default => undef, accept => [qw( yes no )], context => [qw( global )] }, safe_commands => { default => undef, accept => [qw( yes no )], context => [qw( global )] },
btrfs_commit_delete => { default => undef, accept => [qw( yes no after each )], btrfs_commit_delete => { default => undef, accept => [qw( yes no after each )],
deprecated => { MATCH => { regex => qr/^(?:after|each)$/, warn => 'Please use "btrfs_commit_delete yes|no"', replace_key => "btrfs_commit_delete", replace_value => "yes" } } }, deprecated => { MATCH => { regex => qr/^(?:after|each)$/, warn => 'Please use "btrfs_commit_delete yes|no"', replace_key => "btrfs_commit_delete", replace_value => "yes" } } },
@ -1461,11 +1461,13 @@ sub _btrfs_send_options($$;$$)
my $clone_src = shift // []; my $clone_src = shift // [];
my $send_protocol = config_key($target, "send_protocol"); my $send_protocol = config_key($target, "send_protocol");
my $send_compressed_data = config_key($target, "send_compressed_data"); my $send_compressed_data = config_key($target, "send_compressed_data");
my $compat_synology = config_key_lru($target, "compat", "synology");
my @send_options; my @send_options;
push(@send_options, '-p', { unsafe => $parent->{PATH} } ) if($parent); push(@send_options, '-p', { unsafe => $parent->{PATH} } ) if($parent);
push(@send_options, '-c', { unsafe => $_ } ) foreach(map { $_->{PATH} } @$clone_src); push(@send_options, '-c', { unsafe => $_ } ) foreach(map { $_->{PATH} } @$clone_src);
push(@send_options, '--proto', $send_protocol ) if($send_protocol); push(@send_options, '--proto', $send_protocol ) if($send_protocol);
push(@send_options, '--compressed-data' ) if($send_compressed_data); push(@send_options, '--compressed-data' ) if($send_compressed_data);
push(@send_options, '--without-syno-features' ) if($compat_synology);
#push(@send_options, '-v') if($loglevel >= 3); #push(@send_options, '-v') if($loglevel >= 3);
return \@send_options; return \@send_options;
} }

View File

@ -202,3 +202,18 @@ volume ssh://my-remote-host.com/mnt/btr_pool
snapshot_preserve_min all snapshot_preserve_min all
subvolume home subvolume home
target /mnt/btr_backup/my-remote-host.com target /mnt/btr_backup/my-remote-host.com
# Archive all shared folders from a Synology NAS btrfs.
# Needs an admin account with SSH key login.
volume ssh://my-synology-host.com/volume1
subvolume *
compat synology
snapshot_dir btrbk_snapshots
snapshot_create ondemand
snapshot_preserve_min latest
snapshot_preserve no
target_preserve_min 6m
target_preserve 10d 10w 12m
target /mnt/btr_backup/my-synology-host.com

View File

@ -417,6 +417,12 @@ with "ERROR: attribute 12 requested but not present".
Note that there is *no guarantee that backups created with this Note that there is *no guarantee that backups created with this
option enabled can be restored at all*. option enabled can be restored at all*.
*synology*::
Useful when transfering snapshots from Synology DSM NAS systems, that
are normally not compatible with standard Btrfs systems and sending
would cause a lot of ACL errors. When this is enabled, the option
`--without-syno-features` is passed to `btrfs send`.
If you want to set this option for local or remote hosts only, set If you want to set this option for local or remote hosts only, set
*compat_local* or *compat_remote* (e.g. "compat_remote busybox"). *compat_local* or *compat_remote* (e.g. "compat_remote busybox").
-- --