[pbs-devel] [PATCH backup-qemu 1/2] add support for notes

Filip Schauer f.schauer at proxmox.com
Mon May 27 15:07:14 CEST 2024


Allow adding a comment/notes to a new backup.

Signed-off-by: Filip Schauer <f.schauer at proxmox.com>
---
 src/backup.rs | 6 +++++-
 src/lib.rs    | 9 +++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/backup.rs b/src/backup.rs
index bbe4f00..b7d383a 100644
--- a/src/backup.rs
+++ b/src/backup.rs
@@ -73,7 +73,11 @@ impl BackupTask {
 
         let (abort, _) = tokio::sync::broadcast::channel(16);
 
-        let manifest = Arc::new(Mutex::new(BackupManifest::new(setup.backup_dir.clone())));
+        let mut manifest = BackupManifest::new(setup.backup_dir.clone());
+        if let Some(notes) = &setup.notes {
+            manifest.unprotected["notes"] = serde_json::Value::String(notes.clone());
+        }
+        let manifest = Arc::new(Mutex::new(manifest));
 
         let registry = Arc::new(Mutex::new(Registry::<ImageUploadInfo>::new()));
         let known_chunks = Arc::new(Mutex::new(HashSet::new()));
diff --git a/src/lib.rs b/src/lib.rs
index 9067fc5..034b7ab 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -140,6 +140,7 @@ pub(crate) struct BackupSetup {
     pub key_password: Option<String>,
     pub master_keyfile: Option<std::path::PathBuf>,
     pub fingerprint: Option<String>,
+    pub notes: Option<String>,
 }
 
 // helper class to implement synchrounous interface
@@ -212,6 +213,7 @@ pub extern "C" fn proxmox_backup_new(
     compress: bool,
     encrypt: bool,
     fingerprint: *const c_char,
+    notes: *const c_char,
     error: *mut *mut c_char,
 ) -> *mut ProxmoxBackupHandle {
     proxmox_backup_new_ns(
@@ -227,6 +229,7 @@ pub extern "C" fn proxmox_backup_new(
         compress,
         encrypt,
         fingerprint,
+        notes,
         error,
     )
 }
@@ -251,6 +254,7 @@ pub extern "C" fn proxmox_backup_new_ns(
     compress: bool,
     encrypt: bool,
     fingerprint: *const c_char,
+    notes: *const c_char,
     error: *mut *mut c_char,
 ) -> *mut ProxmoxBackupHandle {
     let task: Result<_, Error> = try_block!({
@@ -277,6 +281,8 @@ pub extern "C" fn proxmox_backup_new_ns(
             return Err(format_err!("can't use master keyfile without keyfile"));
         }
 
+        let notes = tools::utf8_c_string(notes)?;
+
         let crypt_mode = if keyfile.is_some() {
             if encrypt {
                 CryptMode::Encrypt
@@ -304,6 +310,7 @@ pub extern "C" fn proxmox_backup_new_ns(
             key_password,
             master_keyfile,
             fingerprint,
+            notes,
         };
 
         BackupTask::new(setup, compress, crypt_mode)
@@ -816,6 +823,7 @@ pub extern "C" fn proxmox_restore_new(
             key_password,
             master_keyfile: None,
             fingerprint,
+            notes: None,
         };
 
         RestoreTask::new(setup)
@@ -876,6 +884,7 @@ pub extern "C" fn proxmox_restore_new_ns(
             key_password,
             master_keyfile: None,
             fingerprint,
+            notes: None,
         };
 
         RestoreTask::new(setup)
-- 
2.39.2





More information about the pbs-devel mailing list