public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] backup: check verify state of previous backup before allowing reuse
@ 2020-09-01 10:33 Stefan Reiter
  2020-09-01 13:47 ` Dominik Csapak
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Reiter @ 2020-09-01 10:33 UTC (permalink / raw)
  To: pbs-devel

Do not allow clients to reuse chunks from the previous backup if it has
a failed validation result. This would result in a new "successful"
backup that potentially references broken chunks.

If the previous backup has not been verified, assume it is fine and
continue on.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---
 src/api2/backup.rs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/api2/backup.rs b/src/api2/backup.rs
index ad608d85..c0b1d985 100644
--- a/src/api2/backup.rs
+++ b/src/api2/backup.rs
@@ -652,6 +652,19 @@ fn download_previous(
             None => bail!("no previous backup"),
         };
 
+        let (manifest, _) = env.datastore.load_manifest(&last_backup.backup_dir)?;
+        let verify = manifest.unprotected["verify_state"].clone();
+        match serde_json::from_value::<SnapshotVerifyState>(verify) {
+            Ok(verify) => {
+                if verify.state != "ok" {
+                    bail!("previous backup has failed verification");
+                }
+            },
+            Err(_) => {
+                // no verify state found, ignore and treat as valid
+            }
+        };
+
         let mut path = env.datastore.snapshot_path(&last_backup.backup_dir);
         path.push(&archive_name);
 
-- 
2.20.1





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup] backup: check verify state of previous backup before allowing reuse
  2020-09-01 10:33 [pbs-devel] [PATCH proxmox-backup] backup: check verify state of previous backup before allowing reuse Stefan Reiter
@ 2020-09-01 13:47 ` Dominik Csapak
  0 siblings, 0 replies; 2+ messages in thread
From: Dominik Csapak @ 2020-09-01 13:47 UTC (permalink / raw)
  To: pbs-devel

sadly this is not enough to handle this in a good way

short excerpt from src/backup/chunk_store.rs
fn insert_chunk ...
--->8---
if let Ok(metadata) = std::fs::metadata(&chunk_path) {
     if metadata.is_file() {
         return Ok((true, metadata.len()));
     } else {
         bail!("Got unexpected file type on store '{}' for chunk {}", 
self.name, digest_str);
     }
}
---8<---

so if the chunk already exists, the server does not write it again
we need here some 'force' parameter that overwrites the corrupt chunks

otherwise the client sends all chunks, but the server never writes them

On 9/1/20 12:33 PM, Stefan Reiter wrote:
> Do not allow clients to reuse chunks from the previous backup if it has
> a failed validation result. This would result in a new "successful"
> backup that potentially references broken chunks.
> 
> If the previous backup has not been verified, assume it is fine and
> continue on.
> 
> Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
> ---
>   src/api2/backup.rs | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/src/api2/backup.rs b/src/api2/backup.rs
> index ad608d85..c0b1d985 100644
> --- a/src/api2/backup.rs
> +++ b/src/api2/backup.rs
> @@ -652,6 +652,19 @@ fn download_previous(
>               None => bail!("no previous backup"),
>           };
>   
> +        let (manifest, _) = env.datastore.load_manifest(&last_backup.backup_dir)?;
> +        let verify = manifest.unprotected["verify_state"].clone();
> +        match serde_json::from_value::<SnapshotVerifyState>(verify) {
> +            Ok(verify) => {
> +                if verify.state != "ok" {
> +                    bail!("previous backup has failed verification");
> +                }
> +            },
> +            Err(_) => {
> +                // no verify state found, ignore and treat as valid
> +            }
> +        };
> +
>           let mut path = env.datastore.snapshot_path(&last_backup.backup_dir);
>           path.push(&archive_name);
>   
> 





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-01 13:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 10:33 [pbs-devel] [PATCH proxmox-backup] backup: check verify state of previous backup before allowing reuse Stefan Reiter
2020-09-01 13:47 ` Dominik Csapak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal