From c553407e989fa9007a9fcb97ccc0d6db3141a9a2 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 25 Mar 2021 13:08:34 +0100 Subject: [PATCH] tape: add --scan option for catalog restore --- src/api2/tape/drive.rs | 19 +++++++++++++++---- src/bin/proxmox-tape.rs | 5 +++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs index a5dae732..b753eb5b 100644 --- a/src/api2/tape/drive.rs +++ b/src/api2/tape/drive.rs @@ -1227,6 +1227,11 @@ pub async fn status(drive: String) -> Result { type: bool, optional: true, }, + scan: { + description: "Re-read the whole tape to reconstruct the catalog instead of restoring saved versions.", + type: bool, + optional: true, + }, verbose: { description: "Verbose mode - log all found chunks.", type: bool, @@ -1245,11 +1250,13 @@ pub async fn status(drive: String) -> Result { pub fn catalog_media( drive: String, force: Option, + scan: Option, verbose: Option, rpcenv: &mut dyn RpcEnvironment, ) -> Result { let verbose = verbose.unwrap_or(false); let force = force.unwrap_or(false); + let scan = scan.unwrap_or(false); let upid_str = run_drive_worker( rpcenv, @@ -1318,13 +1325,17 @@ pub fn catalog_media( bail!("media catalog exists (please use --force to overwrite)"); } - let media_set = inventory.compute_media_set_members(media_set_uuid)?; + if !scan { + let media_set = inventory.compute_media_set_members(media_set_uuid)?; - if fast_catalog_restore(&worker, &mut drive, &media_set, &media_id.label.uuid)? { - return Ok(()) + if fast_catalog_restore(&worker, &mut drive, &media_set, &media_id.label.uuid)? { + return Ok(()) + } + + task_log!(worker, "no catalog found"); } - task_log!(worker, "no catalog found - scaning entire media now"); + task_log!(worker, "scanning entire media to reconstruct catalog"); drive.rewind()?; drive.read_label()?; // skip over labels - we already read them above diff --git a/src/bin/proxmox-tape.rs b/src/bin/proxmox-tape.rs index f947cdc9..cddac1b4 100644 --- a/src/bin/proxmox-tape.rs +++ b/src/bin/proxmox-tape.rs @@ -911,6 +911,11 @@ async fn restore(mut param: Value) -> Result<(), Error> { type: bool, optional: true, }, + scan: { + description: "Re-read the whole tape to reconstruct the catalog instead of restoring saved versions.", + type: bool, + optional: true, + }, verbose: { description: "Verbose mode - log all found chunks.", type: bool,