* [pbs-devel] [PATCH v3 proxmox-backup] backup: don't validate chunk existance if base was recently verified
@ 2020-09-30 15:37 Stefan Reiter
0 siblings, 0 replies; only message in thread
From: Stefan Reiter @ 2020-09-30 15:37 UTC (permalink / raw)
To: pbs-devel
If the base was successfully verified within the last 7 days, we assume
that it is okay and all chunks exist, so we don't have to check.
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---
src/api2/backup/environment.rs | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/api2/backup/environment.rs b/src/api2/backup/environment.rs
index d515bf30..7410891f 100644
--- a/src/api2/backup/environment.rs
+++ b/src/api2/backup/environment.rs
@@ -5,7 +5,7 @@ use std::collections::HashMap;
use ::serde::{Serialize};
use serde_json::{json, Value};
-use proxmox::tools::digest_to_hex;
+use proxmox::tools::{digest_to_hex, time};
use proxmox::tools::fs::{replace_file, CreateOptions};
use proxmox::api::{RpcEnvironment, RpcEnvironmentType};
@@ -457,6 +457,31 @@ impl BackupEnvironment {
Ok(())
}
+ fn last_backup_has_recent_verify(&self) -> Result<bool, Error> {
+ match &self.last_backup {
+ Some(last_backup) => {
+ let last_dir = &last_backup.backup_dir;
+ let (manifest, _) = self.datastore.load_manifest(last_dir)?;
+ let verify = manifest.unprotected["verify_state"].clone();
+ match serde_json::from_value::<Option<SnapshotVerifyState>>(verify) {
+ Ok(verify) => match verify {
+ Some(verify) => {
+ // consider one week recent enough to not warrant a validate
+ let cutoff = time::epoch_i64() - 60*60*24*7;
+ Ok(verify.state == VerifyState::Ok && verify.upid.starttime > cutoff)
+ },
+ None => Ok(false)
+ },
+ Err(err) => {
+ self.worker.warn(format!("error parsing base verification state : '{}'", err));
+ Ok(false)
+ }
+ }
+ },
+ None => Ok(false)
+ }
+ }
+
/// Ensure all chunks referenced in this backup actually exist.
/// Only call *after* all writers have been closed, to avoid race with GC.
/// In case of error, mark the previous backup as 'verify failed'.
@@ -534,7 +559,9 @@ impl BackupEnvironment {
}
}
- self.verify_chunk_existance(&state.known_chunks)?;
+ if !self.last_backup_has_recent_verify()? {
+ self.verify_chunk_existance(&state.known_chunks)?;
+ }
// marks the backup as successful
state.finished = true;
--
2.20.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-30 15:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-30 15:37 [pbs-devel] [PATCH v3 proxmox-backup] backup: don't validate chunk existance if base was recently verified Stefan Reiter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox