From: Cheng-Ling Lai Date: Sat, 7 Feb 2026 02:35:46 +0000 (+0800) Subject: Remove source_path from BackupConfig X-Git-Tag: v0.13.1~31^2 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1102%2Fhead;p=thirdparty%2Fsnapper.git Remove source_path from BackupConfig --- diff --git a/client/snbk/BackupConfig.cc b/client/snbk/BackupConfig.cc index 661b5041..ba44596d 100644 --- a/client/snbk/BackupConfig.cc +++ b/client/snbk/BackupConfig.cc @@ -52,9 +52,6 @@ namespace snapper if (!toValue(tmp1, target_mode, false)) SN_THROW(Exception(sformat("unknown target-mode '%s' in '%s'", tmp1.c_str(), name.c_str()))); - if (!get_child_value(json_file.get_root(), "source-path", source_path)) - SN_THROW(Exception(sformat("source-path entry not found in '%s'", name.c_str()))); - if (!get_child_value(json_file.get_root(), "target-path", target_path)) SN_THROW(Exception(sformat("target-path entry not found in '%s'", name.c_str()))); diff --git a/client/snbk/BackupConfig.h b/client/snbk/BackupConfig.h index f92c3d37..c3b47c1e 100644 --- a/client/snbk/BackupConfig.h +++ b/client/snbk/BackupConfig.h @@ -57,7 +57,6 @@ namespace snapper TargetMode target_mode = TargetMode::LOCAL; - string source_path; string target_path; bool automatic = false; diff --git a/client/snbk/TheBigThing.cc b/client/snbk/TheBigThing.cc index 9a7b8e46..dcec671a 100644 --- a/client/snbk/TheBigThing.cc +++ b/client/snbk/TheBigThing.cc @@ -109,9 +109,10 @@ namespace snapper return nodes; } - string source_snapshot_dir(const BackupConfig& backup_config, unsigned int num) + string source_snapshot_dir(const ProxySnapper* snapper, unsigned int num) { - return backup_config.source_path + "/" SNAPSHOTS_NAME "/" + to_string(num); + return snapper->getConfig().getSubvolume() + "/" SNAPSHOTS_NAME "/" + + to_string(num); } string target_snapshot_dir(const BackupConfig& backup_config, unsigned int num) @@ -356,7 +357,7 @@ namespace snapper spec_source.shell = backup_config.get_source_shell(); spec_source.mkdir_bin = MKDIR_BIN; spec_source.btrfs_bin = BTRFS_BIN; - spec_source.snapshot_dir = source_snapshot_dir(backup_config, num); + spec_source.snapshot_dir = source_snapshot_dir(the_big_things.snapper, num); CopySpec spec_target; // Copy specification for the snapshot on the target. spec_target.shell = backup_config.get_target_shell(); @@ -381,7 +382,8 @@ namespace snapper the_big_things.source_tree.find_nearest_valid_node(source_uuid)) { spec_source.parent_subvol_path = - source_snapshot_dir(backup_config, parent->node->get_number()) + + source_snapshot_dir(the_big_things.snapper, + parent->node->get_number()) + "/" SNAPSHOT_NAME; } @@ -437,14 +439,6 @@ namespace snapper target_btrfs_version(backup_config.target_btrfs_bin, backup_config.get_target_shell()), snapper(snappers->getSnapper(backup_config.config)), locker(snapper) { - if (backup_config.source_path != snapper->getConfig().getSubvolume()) - { - string error = sformat(_("Path mismatch between source-path of backup-config and subvolume of " - "snapper config ('%s' vs. '%s')."), backup_config.source_path.c_str(), - snapper->getConfig().getSubvolume().c_str()); - SN_THROW(Exception(error)); - } - probe_source(backup_config, verbose); probe_target(backup_config, verbose); @@ -479,8 +473,9 @@ namespace snapper // Query additional information (uuids, read-only) from btrfs. - CmdBtrfsSubvolumeShow extra(BTRFS_BIN, shell_source, backup_config.source_path + "/" SNAPSHOTS_NAME "/" + - to_string(num) + "/" SNAPSHOT_NAME); + CmdBtrfsSubvolumeShow extra(BTRFS_BIN, shell_source, + source_snapshot_dir(snapper, num) + + "/" SNAPSHOT_NAME); TheBigThing the_big_thing(num); the_big_thing.date = source_snapshot.getDate(); diff --git a/client/snbk/TheBigThing.h b/client/snbk/TheBigThing.h index 338bc623..7901467e 100644 --- a/client/snbk/TheBigThing.h +++ b/client/snbk/TheBigThing.h @@ -163,9 +163,10 @@ namespace snapper TreeView source_tree; TreeView target_tree; + const ProxySnapper* snapper; + private: - const ProxySnapper* snapper; const Locker locker; vector the_big_things; diff --git a/client/snbk/cmd-list-configs.cc b/client/snbk/cmd-list-configs.cc index 11e7958e..64364ba9 100644 --- a/client/snbk/cmd-list-configs.cc +++ b/client/snbk/cmd-list-configs.cc @@ -53,7 +53,7 @@ namespace snapper enum class Column { - NAME, CONFIG, TARGET_MODE, AUTOMATIC, SOURCE_PATH, TARGET_PATH, SSH_HOST, + NAME, CONFIG, TARGET_MODE, AUTOMATIC, TARGET_PATH, SSH_HOST, SSH_USER, SSH_PORT, SSH_IDENTITY, TARGET_BTRFS_BIN, TARGET_LS_BIN, TARGET_MKDIR_BIN, TARGET_RM_BIN, TARGET_RMDIR_BIN }; @@ -76,9 +76,6 @@ namespace snapper case Column::AUTOMATIC: return Cell(_("Automatic")); - case Column::SOURCE_PATH: - return Cell(_("Source Path")); - case Column::TARGET_PATH: return Cell(_("Target Path")); @@ -132,9 +129,6 @@ namespace snapper case Column::AUTOMATIC: return backup_config.automatic; - case Column::SOURCE_PATH: - return backup_config.source_path; - case Column::TARGET_PATH: return backup_config.target_path; @@ -290,11 +284,11 @@ namespace snapper } const vector some_columns = { Column::NAME, Column::CONFIG, Column::TARGET_MODE, - Column::AUTOMATIC, Column::SOURCE_PATH, Column::TARGET_PATH, Column::SSH_HOST, + Column::AUTOMATIC, Column::TARGET_PATH, Column::SSH_HOST, Column::SSH_USER, Column::SSH_PORT, Column::SSH_IDENTITY }; const vector all_columns = { Column::NAME, Column::CONFIG, Column::TARGET_MODE, - Column::AUTOMATIC, Column::SOURCE_PATH, Column::TARGET_PATH, Column::SSH_HOST, + Column::AUTOMATIC, Column::TARGET_PATH, Column::SSH_HOST, Column::SSH_USER, Column::SSH_PORT, Column::SSH_IDENTITY, Column::TARGET_BTRFS_BIN, Column::TARGET_LS_BIN, Column::TARGET_MKDIR_BIN, Column::TARGET_RM_BIN, Column::TARGET_RMDIR_BIN @@ -320,7 +314,7 @@ namespace snapper template <> struct EnumInfo { static const vector names; }; const vector EnumInfo::names({ - "name", "config", "target-mode", "automatic", "source-path", "target-path", "ssh-host", + "name", "config", "target-mode", "automatic", "target-path", "ssh-host", "ssh-user", "ssh-port", "ssh-identity", "target-btrfs-bin", "target-ls-bin", "target-mkdir-bin", "target-rm-bin", "target-rmdir-bin" }); diff --git a/client/snbk/cmd-list.cc b/client/snbk/cmd-list.cc index c0ed98f9..6b1ec7a3 100644 --- a/client/snbk/cmd-list.cc +++ b/client/snbk/cmd-list.cc @@ -232,8 +232,7 @@ namespace snapper if (backup_configs.size() > 1) { cout << "Backup-config:" << backup_config.name << ", config:" << backup_config.config - << ", source-path:" << backup_config.source_path << ", target-mode:" - << toString(backup_config.target_mode) << endl; + << ", target-mode:" << toString(backup_config.target_mode) << endl; } try