From: Stefan Reiter <s.reiter@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/5] backup: don't validate chunk existance if base was recently verified
Date: Wed, 30 Sep 2020 15:25:18 +0200 [thread overview]
Message-ID: <20200930132522.22927-2-s.reiter@proxmox.com> (raw)
In-Reply-To: <20200930132522.22927-1-s.reiter@proxmox.com>
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 | 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
+ 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
next prev parent reply other threads:[~2020-09-30 13:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-30 13:25 [pbs-devel] [PATCH 0/5] backup validation improvements Stefan Reiter
2020-09-30 13:25 ` Stefan Reiter [this message]
2020-09-30 13:32 ` [pbs-devel] [PATCH proxmox-backup 1/5] backup: don't validate chunk existance if base was recently verified Thomas Lamprecht
2020-09-30 13:42 ` Stefan Reiter
2020-09-30 13:55 ` Thomas Lamprecht
2020-09-30 13:25 ` [pbs-devel] [RFC proxmox-backup 2/5] ParallelHandler: add unbounded mode Stefan Reiter
2020-09-30 13:25 ` [pbs-devel] [RFC proxmox-backup 3/5] ParallelHandler: add check_abort function and handle errors during join Stefan Reiter
2020-09-30 13:25 ` [pbs-devel] [RFC proxmox-backup 4/5] ParallelHandler: exit early if this or other thread aborted Stefan Reiter
2020-09-30 13:25 ` [pbs-devel] [RFC proxmox-backup 5/5] backup: validate chunk existance in background Stefan Reiter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200930132522.22927-2-s.reiter@proxmox.com \
--to=s.reiter@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox