Skip to content

Commit

Permalink
Merge pull request #971 from aschnell/master
Browse files Browse the repository at this point in the history
- make some binary paths used in snbk configurable
  • Loading branch information
aschnell authored Dec 17, 2024
2 parents ed27988 + 1c87238 commit 13992f3
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 19 deletions.
4 changes: 4 additions & 0 deletions client/snbk/BackupConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
5 changes: 5 additions & 0 deletions client/snbk/BackupConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <vector>

#include <snapper/Enum.h>
#include <snapper/SnapperDefines.h>

#include "Shell.h"

Expand Down Expand Up @@ -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<string> ssh_options() const;
Expand Down
8 changes: 4 additions & 4 deletions client/snbk/CmdBtrfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions client/snbk/CmdBtrfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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; }
Expand Down
4 changes: 2 additions & 2 deletions client/snbk/CmdFindmnt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion client/snbk/CmdFindmnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
4 changes: 2 additions & 2 deletions client/snbk/CmdRealpath.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion client/snbk/CmdRealpath.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
10 changes: 5 additions & 5 deletions client/snbk/TheBigThing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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())
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
26 changes: 24 additions & 2 deletions doc/snapper-backup-configs.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<refentry id='snapper-backup-configs5'>

<refentryinfo>
<date>2024-11-05</date>
<date>2024-12-17</date>
</refentryinfo>

<refmeta>
<refentrytitle>snapper-backup-configs</refentrytitle>
<manvolnum>5</manvolnum>
<refmiscinfo class='date'>2024-11-05</refmiscinfo>
<refmiscinfo class='date'>2024-12-17</refmiscinfo>
<refmiscinfo class='version'>@VERSION@</refmiscinfo>
<refmiscinfo class='manual'>Filesystem Snapshot Management</refmiscinfo>
</refmeta>
Expand Down Expand Up @@ -101,6 +101,28 @@
password or passphrase. Optional for target mode ssh-push.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><option>target-btrfs-bin</option></term>
<listitem>
<para>Location of the btrfs binary on the target. Optional.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><option>target-realpath-bin</option></term>
<listitem>
<para>Location of the realpath binary on the target. Optional.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><option>target-findmnt-bin</option></term>
<listitem>
<para>Location of the findmnt binary on the target. Optional.</para>
</listitem>
</varlistentry>

</variablelist>
</refsect1>

Expand Down
6 changes: 6 additions & 0 deletions package/snapper.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Dec 17 09:14:46 CET 2024 - [email protected]

- make some binary paths used in snbk configurable
(gh#openSUSE/snapper#970)

-------------------------------------------------------------------
Mon Dec 02 16:51:50 CET 2024 - [email protected]

Expand Down

0 comments on commit 13992f3

Please sign in to comment.