[pbs-devel] [PATCH proxmox-backup] backup: check verify state of previous backup before allowing reuse

Dominik Csapak d.csapak at proxmox.com
Tue Sep 1 15:47:05 CEST 2020


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 at 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);
>   
> 






More information about the pbs-devel mailing list