diff --git a/client/snbk/BackupConfig.cc b/client/snbk/BackupConfig.cc index 9d31a85b..b55df94a 100644 --- a/client/snbk/BackupConfig.cc +++ b/client/snbk/BackupConfig.cc @@ -69,6 +69,10 @@ namespace snapper get_child_value(json_file.get_root(), "ssh-user", ssh_user); get_child_value(json_file.get_root(), "ssh-identity", ssh_identity); } + + get_child_value(json_file.get_root(), "target-btrfs-bin", target_btrfs_bin); + get_child_value(json_file.get_root(), "target-realpath-bin", target_realpath_bin); + get_child_value(json_file.get_root(), "target-findmnt-bin", target_findmnt_bin); } diff --git a/client/snbk/BackupConfig.h b/client/snbk/BackupConfig.h index 254bc843..2bd5731e 100644 --- a/client/snbk/BackupConfig.h +++ b/client/snbk/BackupConfig.h @@ -27,6 +27,7 @@ #include #include +#include #include "Shell.h" @@ -68,6 +69,10 @@ namespace snapper Shell get_source_shell() const; Shell get_target_shell() const; + string target_btrfs_bin = BTRFS_BIN; + string target_realpath_bin = REALPATH_BIN; + string target_findmnt_bin = FINDMNT_BIN; + private: vector ssh_options() const; diff --git a/client/snbk/CmdBtrfs.cc b/client/snbk/CmdBtrfs.cc index ac98b504..34f9239a 100644 --- a/client/snbk/CmdBtrfs.cc +++ b/client/snbk/CmdBtrfs.cc @@ -39,9 +39,9 @@ namespace snapper using namespace std; - CmdBtrfsSubvolumeList::CmdBtrfsSubvolumeList(const Shell& shell, const string& mount_point) + CmdBtrfsSubvolumeList::CmdBtrfsSubvolumeList(const string& btrfs_bin, const Shell& shell, const string& mount_point) { - SystemCmd::Args cmd_args = { BTRFS_BIN, "subvolume", "list", "-a", "-puqR", mount_point }; + SystemCmd::Args cmd_args = { btrfs_bin, "subvolume", "list", "-a", "-puqR", mount_point }; SystemCmd cmd(shellify(shell, cmd_args)); if (cmd.retcode() != 0) @@ -157,9 +157,9 @@ namespace snapper } - CmdBtrfsSubvolumeShow::CmdBtrfsSubvolumeShow(const Shell& shell, const string& mount_point) + CmdBtrfsSubvolumeShow::CmdBtrfsSubvolumeShow(const string& btrfs_bin, const Shell& shell, const string& mount_point) { - SystemCmd::Args cmd_args = { BTRFS_BIN, "subvolume", "show", mount_point }; + SystemCmd::Args cmd_args = { btrfs_bin, "subvolume", "show", mount_point }; SystemCmd cmd(shellify(shell, cmd_args)); if (cmd.retcode() != 0) diff --git a/client/snbk/CmdBtrfs.h b/client/snbk/CmdBtrfs.h index db10c504..86a7e558 100644 --- a/client/snbk/CmdBtrfs.h +++ b/client/snbk/CmdBtrfs.h @@ -46,7 +46,7 @@ namespace snapper static const long top_level_id = 5; static const long unknown_id = -1; - CmdBtrfsSubvolumeList(const Shell& shell, const string& mount_point); + CmdBtrfsSubvolumeList(const string& btrfs_bin, const Shell& shell, const string& mount_point); /** * Entry for every subvolume (unfortunately except the top-level). @@ -93,7 +93,7 @@ namespace snapper { public: - CmdBtrfsSubvolumeShow(const Shell& shell, const string& mount_point); + CmdBtrfsSubvolumeShow(const string& btrfs_bin, const Shell& shell, const string& mount_point); const string& get_uuid() const { return uuid; } const string& get_parent_uuid() const { return parent_uuid; } diff --git a/client/snbk/CmdFindmnt.cc b/client/snbk/CmdFindmnt.cc index 4844c8b6..ecda2aaa 100644 --- a/client/snbk/CmdFindmnt.cc +++ b/client/snbk/CmdFindmnt.cc @@ -32,10 +32,10 @@ namespace snapper { - CmdFindmnt::CmdFindmnt(const Shell& shell, const string& path) + CmdFindmnt::CmdFindmnt(const string& findmnt_bin, const Shell& shell, const string& path) : path(path) { - SystemCmd::Args cmd_args = { FINDMNT_BIN, "--json", "--target", path }; + SystemCmd::Args cmd_args = { findmnt_bin, "--json", "--target", path }; SystemCmd cmd(shellify(shell, cmd_args)); if (cmd.retcode() != 0) diff --git a/client/snbk/CmdFindmnt.h b/client/snbk/CmdFindmnt.h index 09cbea96..9a251419 100644 --- a/client/snbk/CmdFindmnt.h +++ b/client/snbk/CmdFindmnt.h @@ -41,7 +41,7 @@ namespace snapper { public: - CmdFindmnt(const Shell& shell, const string& path); + CmdFindmnt(const string& findmnt_bin, const Shell& shell, const string& path); const string& get_source() const { return source; } const string& get_target() const { return target; } diff --git a/client/snbk/CmdRealpath.cc b/client/snbk/CmdRealpath.cc index 9600fdcb..0eb417ab 100644 --- a/client/snbk/CmdRealpath.cc +++ b/client/snbk/CmdRealpath.cc @@ -31,10 +31,10 @@ namespace snapper { - CmdRealpath::CmdRealpath(const Shell& shell, const string& path) + CmdRealpath::CmdRealpath(const string& realpath_bin, const Shell& shell, const string& path) : path(path) { - SystemCmd::Args cmd_args = { REALPATH_BIN, path }; + SystemCmd::Args cmd_args = { realpath_bin, path }; SystemCmd cmd(shellify(shell, cmd_args)); if (cmd.retcode() != 0) diff --git a/client/snbk/CmdRealpath.h b/client/snbk/CmdRealpath.h index 9668713d..c69afb62 100644 --- a/client/snbk/CmdRealpath.h +++ b/client/snbk/CmdRealpath.h @@ -41,7 +41,7 @@ namespace snapper { public: - CmdRealpath(const Shell& shell, const string& path); + CmdRealpath(const string& realpath_bin, const Shell& shell, const string& path); const string& get_realpath() const { return realpath; } diff --git a/client/snbk/TheBigThing.cc b/client/snbk/TheBigThing.cc index af7046f0..3e6eb2f6 100644 --- a/client/snbk/TheBigThing.cc +++ b/client/snbk/TheBigThing.cc @@ -267,7 +267,7 @@ namespace snapper // Query additional information (uuids, read-only) from btrfs. - CmdBtrfsSubvolumeShow extra(shell_source, backup_config.source_path + "/" SNAPSHOTS_NAME "/" + + CmdBtrfsSubvolumeShow extra(BTRFS_BIN, shell_source, backup_config.source_path + "/" SNAPSHOTS_NAME "/" + to_string(num) + "/" SNAPSHOT_NAME); TheBigThing the_big_thing(num); @@ -297,10 +297,10 @@ namespace snapper // In case the target-path is a symbolic link (or includes things like "/../") we // need a lookup for the realpath first. - CmdRealpath cmd_realpath(shell_target, backup_config.target_path); + CmdRealpath cmd_realpath(backup_config.target_realpath_bin, shell_target, backup_config.target_path); const string target_path = cmd_realpath.get_realpath(); - CmdFindmnt cmd_findmnt(shell_target, target_path); + CmdFindmnt cmd_findmnt(backup_config.target_findmnt_bin, shell_target, target_path); const string mount_point = cmd_findmnt.get_target(); if (target_path.size() < mount_point.size()) @@ -309,7 +309,7 @@ namespace snapper if (!boost::starts_with(target_path, mount_point)) SN_THROW(Exception("unsupported target-path setup")); - CmdBtrfsSubvolumeList target_snapshots(shell_target, mount_point); + CmdBtrfsSubvolumeList target_snapshots(backup_config.target_btrfs_bin, shell_target, mount_point); string start; if (target_path != mount_point) @@ -339,7 +339,7 @@ namespace snapper // Query additional information (receive-uuid, read-only) from btrfs. - CmdBtrfsSubvolumeShow y(shell_target, target_path + "/" + path); + CmdBtrfsSubvolumeShow y(backup_config.target_btrfs_bin, shell_target, target_path + "/" + path); bool is_read_only = y.is_read_only(); if (!is_read_only) diff --git a/doc/snapper-backup-configs.xml.in b/doc/snapper-backup-configs.xml.in index 88283595..a486fa3b 100644 --- a/doc/snapper-backup-configs.xml.in +++ b/doc/snapper-backup-configs.xml.in @@ -2,13 +2,13 @@ - 2024-11-05 + 2024-12-17 snapper-backup-configs 5 - 2024-11-05 + 2024-12-17 @VERSION@ Filesystem Snapshot Management @@ -101,6 +101,28 @@ password or passphrase. Optional for target mode ssh-push. + + + + + Location of the btrfs binary on the target. Optional. + + + + + + + Location of the realpath binary on the target. Optional. + + + + + + + Location of the findmnt binary on the target. Optional. + + + diff --git a/package/snapper.changes b/package/snapper.changes index 31c950d4..a1ceecdf 100644 --- a/package/snapper.changes +++ b/package/snapper.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Dec 17 09:14:46 CET 2024 - aschnell@suse.com + +- make some binary paths used in snbk configurable + (gh#openSUSE/snapper#970) + ------------------------------------------------------------------- Mon Dec 02 16:51:50 CET 2024 - aschnell@suse.com