tape: add --scan option for catalog restore

This commit is contained in:
Dietmar Maurer 2021-03-25 13:08:34 +01:00
parent 4830de408b
commit c553407e98
2 changed files with 20 additions and 4 deletions

View File

@ -1227,6 +1227,11 @@ pub async fn status(drive: String) -> Result<LinuxDriveAndMediaStatus, Error> {
type: bool, type: bool,
optional: true, optional: true,
}, },
scan: {
description: "Re-read the whole tape to reconstruct the catalog instead of restoring saved versions.",
type: bool,
optional: true,
},
verbose: { verbose: {
description: "Verbose mode - log all found chunks.", description: "Verbose mode - log all found chunks.",
type: bool, type: bool,
@ -1245,11 +1250,13 @@ pub async fn status(drive: String) -> Result<LinuxDriveAndMediaStatus, Error> {
pub fn catalog_media( pub fn catalog_media(
drive: String, drive: String,
force: Option<bool>, force: Option<bool>,
scan: Option<bool>,
verbose: Option<bool>, verbose: Option<bool>,
rpcenv: &mut dyn RpcEnvironment, rpcenv: &mut dyn RpcEnvironment,
) -> Result<Value, Error> { ) -> Result<Value, Error> {
let verbose = verbose.unwrap_or(false); let verbose = verbose.unwrap_or(false);
let force = force.unwrap_or(false); let force = force.unwrap_or(false);
let scan = scan.unwrap_or(false);
let upid_str = run_drive_worker( let upid_str = run_drive_worker(
rpcenv, rpcenv,
@ -1318,13 +1325,17 @@ pub fn catalog_media(
bail!("media catalog exists (please use --force to overwrite)"); 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)? { if fast_catalog_restore(&worker, &mut drive, &media_set, &media_id.label.uuid)? {
return Ok(()) 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.rewind()?;
drive.read_label()?; // skip over labels - we already read them above drive.read_label()?; // skip over labels - we already read them above

View File

@ -911,6 +911,11 @@ async fn restore(mut param: Value) -> Result<(), Error> {
type: bool, type: bool,
optional: true, optional: true,
}, },
scan: {
description: "Re-read the whole tape to reconstruct the catalog instead of restoring saved versions.",
type: bool,
optional: true,
},
verbose: { verbose: {
description: "Verbose mode - log all found chunks.", description: "Verbose mode - log all found chunks.",
type: bool, type: bool,