tape restore: verify if all chunks exist
This commit is contained in:
parent
5e4d81e957
commit
1369bcdbba
@ -516,7 +516,7 @@ fn restore_archive<'a>(
|
||||
if is_new {
|
||||
task_log!(worker, "restore snapshot {}", backup_dir);
|
||||
|
||||
match restore_snapshot_archive(worker, reader, &path) {
|
||||
match restore_snapshot_archive(worker, reader, &path, &datastore) {
|
||||
Err(err) => {
|
||||
std::fs::remove_dir_all(&path)?;
|
||||
bail!("restore snapshot {} failed - {}", backup_dir, err);
|
||||
@ -667,10 +667,11 @@ fn restore_snapshot_archive<'a>(
|
||||
worker: &WorkerTask,
|
||||
reader: Box<dyn 'a + TapeRead>,
|
||||
snapshot_path: &Path,
|
||||
datastore: &DataStore,
|
||||
) -> Result<bool, Error> {
|
||||
|
||||
let mut decoder = pxar::decoder::sync::Decoder::from_std(reader)?;
|
||||
match try_restore_snapshot_archive(worker, &mut decoder, snapshot_path) {
|
||||
match try_restore_snapshot_archive(worker, &mut decoder, snapshot_path, datastore) {
|
||||
Ok(()) => Ok(true),
|
||||
Err(err) => {
|
||||
let reader = decoder.input();
|
||||
@ -695,6 +696,7 @@ fn try_restore_snapshot_archive<R: pxar::decoder::SeqRead>(
|
||||
worker: &WorkerTask,
|
||||
decoder: &mut pxar::decoder::sync::Decoder<R>,
|
||||
snapshot_path: &Path,
|
||||
datastore: &DataStore,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
let _root = match decoder.next() {
|
||||
@ -785,11 +787,13 @@ fn try_restore_snapshot_archive<R: pxar::decoder::SeqRead>(
|
||||
let index = DynamicIndexReader::open(&archive_path)?;
|
||||
let (csum, size) = index.compute_csum();
|
||||
manifest.verify_file(&item.filename, &csum, size)?;
|
||||
datastore.fast_index_verification(&index)?;
|
||||
}
|
||||
ArchiveType::FixedIndex => {
|
||||
let index = FixedIndexReader::open(&archive_path)?;
|
||||
let (csum, size) = index.compute_csum();
|
||||
manifest.verify_file(&item.filename, &csum, size)?;
|
||||
datastore.fast_index_verification(&index)?;
|
||||
}
|
||||
ArchiveType::Blob => {
|
||||
let mut tmpfile = std::fs::File::open(&archive_path)?;
|
||||
|
@ -153,6 +153,24 @@ impl DataStore {
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Fast index verification - only check if chunks exists
|
||||
pub fn fast_index_verification(&self, index: &dyn IndexFile) -> Result<(), Error> {
|
||||
|
||||
for pos in 0..index.index_count() {
|
||||
let info = index.chunk_info(pos).unwrap();
|
||||
self.stat_chunk(&info.digest).
|
||||
map_err(|err| {
|
||||
format_err!(
|
||||
"fast_index_verification error, stat_chunk {} failed - {}",
|
||||
proxmox::tools::digest_to_hex(&info.digest),
|
||||
err,
|
||||
)
|
||||
})?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &str {
|
||||
self.chunk_store.name()
|
||||
}
|
||||
@ -786,4 +804,3 @@ impl DataStore {
|
||||
self.verify_new
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user