summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Anshul Gupta <ansg191@anshulg.com> 2024-12-14 20:07:45 -0800
committerGravatar Anshul Gupta <ansg191@anshulg.com> 2024-12-14 20:07:45 -0800
commit6cd1d7dc8f6576b18465dd4f4d3f17633feba13f (patch)
treee920da36530954fc03775a7e4795f0e41c8155de
parentf9dc0cb19965e560c413bfdf12794ed75af2ccd4 (diff)
downloadrestic-operator-6cd1d7dc8f6576b18465dd4f4d3f17633feba13f.tar.gz
restic-operator-6cd1d7dc8f6576b18465dd4f4d3f17633feba13f.tar.zst
restic-operator-6cd1d7dc8f6576b18465dd4f4d3f17633feba13f.zip
fix: set hostname of backup to job name
-rw-r--r--src/resticprofile/config.rs3
-rw-r--r--src/resticprofile/mod.rs10
2 files changed, 8 insertions, 5 deletions
diff --git a/src/resticprofile/config.rs b/src/resticprofile/config.rs
index b19ef2e..2669767 100644
--- a/src/resticprofile/config.rs
+++ b/src/resticprofile/config.rs
@@ -115,6 +115,8 @@ pub struct ResticProfileProfileBackup {
pub exclude_if_present: Vec<String>,
/// Max size of the files to be backed up (allowed suffixes: k/K, m/M, g/G, t/T).
pub exclude_larger_than: Option<String>,
+ /// Set the hostname for the snapshot manually.
+ pub host: Option<String>,
/// Same as –exclude pattern but ignores the casing of filenames.
#[serde(skip_serializing_if = "Vec::is_empty")]
#[builder(default)]
@@ -137,7 +139,6 @@ pub struct ResticProfileProfileRetention {
#[serde(skip_serializing_if = "std::ops::Not::not")]
#[builder(default)]
pub before_backup: bool,
- /// Apply retention before starting the backup command
#[builder(default)]
pub host: bool,
diff --git a/src/resticprofile/mod.rs b/src/resticprofile/mod.rs
index c58200f..4ed617f 100644
--- a/src/resticprofile/mod.rs
+++ b/src/resticprofile/mod.rs
@@ -25,9 +25,10 @@ pub struct ResticProfile {
}
impl ResticProfile {
- pub fn new(ns: String, name: impl AsRef<str>, backup: &BackupSpec) -> Self {
- let config = create_config(backup);
- let name = format!("{}-profile", name.as_ref());
+ pub fn new(ns: String, name: impl Into<String>, backup: &BackupSpec) -> Self {
+ let backup_name = name.into();
+ let name = format!("{backup_name}-profile");
+ let config = create_config(backup_name, backup);
ResticProfile { name, ns, config }
}
@@ -99,7 +100,7 @@ impl Deployable for ResticProfile {
}
}
-fn create_config(backup: &BackupSpec) -> ResticProfileConfig {
+fn create_config(name: String, backup: &BackupSpec) -> ResticProfileConfig {
let paths = extract_paths(backup);
let backup_conf = backup.restic.backup.as_ref().map(|b| {
@@ -111,6 +112,7 @@ fn create_config(backup: &BackupSpec) -> ResticProfileConfig {
.maybe_exclude_larger_than(b.exclude_larger_than.clone())
.maybe_iexclude(b.iexclude.clone())
.maybe_tag(b.tag.clone())
+ .host(name)
.build()
});