From 79d1b6f0735c701eaea97be4a1e0e7b6214d6a5e Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Fri, 19 Mar 2021 18:09:05 +0800 Subject: [PATCH] add `BackupEngine.VerifyBackup`, #182 --- backup.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backup.go b/backup.go index 87621dd9..b94efb25 100644 --- a/backup.go +++ b/backup.go @@ -161,6 +161,19 @@ func (b *BackupEngine) PurgeOldBackups(n uint32) error { return nil } +// VerifyBackup checks the file sizes in the backup directory +// against the original sizes of the corresponding files in the db directory. +// It does not check file checksum. +func (b *BackupEngine) VerifyBackup(id int64) error { + var cErr *C.char + C.rocksdb_backup_engine_verify_backup(b.c, C.uint32_t(id), &cErr) + if cErr != nil { + defer C.rocksdb_free(unsafe.Pointer(cErr)) + return errors.New(C.GoString(cErr)) + } + return nil +} + // Close close the backup engine and cleans up state // The backups already taken remain on storage. func (b *BackupEngine) Close() {