[pbs-devel] [PATCH proxmox-backup 1/5] backup: don't validate chunk existance if base was recently verified
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed Sep 30 15:32:53 CEST 2020
On 30.09.20 15:25, Stefan Reiter wrote:
> 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 at proxmox.com>
> ---
> src/api2/backup/environment.rs | 29 ++++++++++++++++++++++++++++-
> 1 file changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/src/api2/backup/environment.rs b/src/api2/backup/environment.rs
> index d515bf30..be06d1dc 100644
> --- a/src/api2/backup/environment.rs
> +++ b/src/api2/backup/environment.rs
> @@ -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) => {
> + let cutoff = unsafe { libc::time(std::ptr::null_mut()) };
> + let cutoff = cutoff - 60*60*24*7; // one week back
Why unsafe and why not our `proxmox::tools::time::epoch_i64()` ?
on another note: we should probably add some helper for getting the
verify state
> + 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;
>
More information about the pbs-devel
mailing list