Verifying cbbackup file integrity

Hi,

We are backing up our Couchbase data using cbbackup. We would like to do some basic checking of our backup files as a sanity check.

I saw some info about doing an integrity check with sqlite3, e.g.:

sqlite3 -line bucketbackup.cbb "pragma integrity_check;"
integrity_check = ok

That looks good, BUT sqlite3 always returns OK/success every time, even if I supply it with a non-existent cbb file. Any ideas why this is? Is this a valid approach?

Also, is there a way to get the item counts of buckets from the .cbb’s? I’d like to to a (rough) comparison of whats expected in a given bucket in the live DB vs. what the backup took. We are on Couchbase Community Server 4.5.x…I see cbbackupmgr has some tools for that, but I don’t think community has it.

Any ideas around this topic are appreciated!

Actually, it looks like sqlite3 returns OK for non-existent .cbb files because it will actually create the .cbb file if one does not exist, and then it checks integrity on the empty DB and thus it comes back as OK.

So this does seem to work as expected:

Test known good backup

$ sqlite3 -line data-0000.cbb "pragma integrity_check;"
integrity_check = ok
$ echo $?
0

Test a corrupted backup

$ cp data-0000.cbb test.cbb
$ echo "messinupyourdataz" > test.cbb
$ sqlite3 -line test.cbb "pragma integrity_check;"
Error: file is encrypted or is not a database
$ echo $?
26

If anyone can help me with the other part of the question, that would be much appreciated!:

Also, is there a way to get the item counts of buckets from the .cbb’s? I’d like to to a (rough) comparison of whats expected in a given bucket in the live DB vs. what the backup took. We are on Couchbase Community Server 4.5.x…I see cbbackupmgr has some tools for that, but I don’t think community has it.