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 {
|
if is_new {
|
||||||
task_log!(worker, "restore snapshot {}", backup_dir);
|
task_log!(worker, "restore snapshot {}", backup_dir);
|
||||||
|
|
||||||
match restore_snapshot_archive(worker, reader, &path) {
|
match restore_snapshot_archive(worker, reader, &path, &datastore) {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
std::fs::remove_dir_all(&path)?;
|
std::fs::remove_dir_all(&path)?;
|
||||||
bail!("restore snapshot {} failed - {}", backup_dir, err);
|
bail!("restore snapshot {} failed - {}", backup_dir, err);
|
||||||
|
@ -667,10 +667,11 @@ fn restore_snapshot_archive<'a>(
|
||||||
worker: &WorkerTask,
|
worker: &WorkerTask,
|
||||||
reader: Box<dyn 'a + TapeRead>,
|
reader: Box<dyn 'a + TapeRead>,
|
||||||
snapshot_path: &Path,
|
snapshot_path: &Path,
|
||||||
|
datastore: &DataStore,
|
||||||
) -> Result<bool, Error> {
|
) -> Result<bool, Error> {
|
||||||
|
|
||||||
let mut decoder = pxar::decoder::sync::Decoder::from_std(reader)?;
|
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),
|
Ok(()) => Ok(true),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
let reader = decoder.input();
|
let reader = decoder.input();
|
||||||
|
@ -695,6 +696,7 @@ fn try_restore_snapshot_archive<R: pxar::decoder::SeqRead>(
|
||||||
worker: &WorkerTask,
|
worker: &WorkerTask,
|
||||||
decoder: &mut pxar::decoder::sync::Decoder<R>,
|
decoder: &mut pxar::decoder::sync::Decoder<R>,
|
||||||
snapshot_path: &Path,
|
snapshot_path: &Path,
|
||||||
|
datastore: &DataStore,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
|
||||||
let _root = match decoder.next() {
|
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 index = DynamicIndexReader::open(&archive_path)?;
|
||||||
let (csum, size) = index.compute_csum();
|
let (csum, size) = index.compute_csum();
|
||||||
manifest.verify_file(&item.filename, &csum, size)?;
|
manifest.verify_file(&item.filename, &csum, size)?;
|
||||||
|
datastore.fast_index_verification(&index)?;
|
||||||
}
|
}
|
||||||
ArchiveType::FixedIndex => {
|
ArchiveType::FixedIndex => {
|
||||||
let index = FixedIndexReader::open(&archive_path)?;
|
let index = FixedIndexReader::open(&archive_path)?;
|
||||||
let (csum, size) = index.compute_csum();
|
let (csum, size) = index.compute_csum();
|
||||||
manifest.verify_file(&item.filename, &csum, size)?;
|
manifest.verify_file(&item.filename, &csum, size)?;
|
||||||
|
datastore.fast_index_verification(&index)?;
|
||||||
}
|
}
|
||||||
ArchiveType::Blob => {
|
ArchiveType::Blob => {
|
||||||
let mut tmpfile = std::fs::File::open(&archive_path)?;
|
let mut tmpfile = std::fs::File::open(&archive_path)?;
|
||||||
|
|
|
@ -153,6 +153,24 @@ impl DataStore {
|
||||||
Ok(out)
|
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 {
|
pub fn name(&self) -> &str {
|
||||||
self.chunk_store.name()
|
self.chunk_store.name()
|
||||||
}
|
}
|
||||||
|
@ -786,4 +804,3 @@ impl DataStore {
|
||||||
self.verify_new
|
self.verify_new
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue