Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to backup a live comdb2 database? #365

Closed
AnDongLi opened this issue Sep 6, 2017 · 5 comments
Closed

Is it possible to backup a live comdb2 database? #365

AnDongLi opened this issue Sep 6, 2017 · 5 comments
Labels

Comments

@AnDongLi
Copy link

AnDongLi commented Sep 6, 2017

I read something about backup general database: the database back-end file is not guaranteed to be in a consistent state at any time while the database is running: the database front-end caches LOTS of things that it hasn't necessarily written back to disk. The back-end file is, in busy databases, frequently in an inconsistent state.

I wonder how comdb2 handle this issue.

@markhannum
Copy link
Contributor

Yes- the comdb2ar utility can be used to perform stable backups against a running database, and this backup is restore-able to a stable database image. The trick is to prevent the deletion of logfiles while the backup is running, and to perform recovery on the restored database. comdb2ar queries a running database for the precise LSN to begin recovery against a restored copy. Loosely speaking, this will be a point prior to the oldest LSN of all outstanding dirty pages. See the handling for cmd_logdelete3 in db/appsock_handler.c -> bdb_get_recovery_start_lsn for the details.

@AnDongLi
Copy link
Author

AnDongLi commented Sep 6, 2017

So for the recovery to succeed there must always be a database running, right?
Is there a test I can run to see the backup and restore?

@markhannum
Copy link
Contributor

No- if the database isn't running comdb2ar will default to running fullrecovery against the restored copy. The incremental_backup_load test verifies that comdb2ar is able to perform a stable full-backup and several subsequent incremental backups against a running database loaded with several active writers. See the documentation on our incremental backup system at the bottom of https://bloomberg.github.io/comdb2/backups.html for more information on incremental backups.

@akshatsikarwar
Copy link
Contributor

No, that's just an optimization. You can always run recovery starting at the oldest log file. So you can copy while db is down as long as log files are not removed.

@AnDongLi
Copy link
Author

AnDongLi commented Sep 6, 2017

I see. Thanks.
I'll try the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants