Back up a running instance without stopping it - #26
Merged
sinhaparth5 merged 1 commit intoAug 20, 2026
Conversation
The only correct backup procedure was "stop the server, copy the data directory, start it again". Copying it live races the metadata against the payload tree and produces a store whose rows name payloads the copy does not contain, which --fsck correctly calls corrupt. For a single binary with no sidecars, "you cannot back it up without downtime" is the gap most likely to stop somebody putting real data behind it. Adds monobucket --checkpoint <dir> and a console action under Settings -> Backup. The metadata goes through RocksDB's checkpoint API and the payload tree is hard-linked, so on one filesystem a backup duplicates no bytes and returns in about the time it takes to flush the write-ahead log. Restore is: stop, point MONOBUCKET_DATA_DIR at the checkpoint, start — a checkpoint is a data directory, so there is no import step. Snapshot-then-link is only half the guarantee. deleteObject unlinks its payload immediately, so a delete landing between the two passes would strip a payload the snapshot still names. StorageEngine::checkpointing_ makes reclamation a no-op for the duration; nothing leaks, because deleteObject writes the orphan record in the same batch that removes the row, so the next pass collects what the window skipped. checkpoint_test.cpp asserts this against a concurrent deleter and fails without the barrier. The CLI form needs a stopped server — one process may open the metadata store at a time — so backing up a running instance is the console's job, because the running process is the only thing that can copy its own store. That endpoint is off until MONOBUCKET_BACKUP_DIR names somewhere it may write, and backups are created inside it under a name that may not contain a separator: the destination arrives over HTTP, and a console session is not a shell on the host. It is gated on a new Permission::BackupWrite rather than settings:write, because a checkpoint copies every S3 secret in the instance. Nothing is scheduled. A copy is written when somebody asks and never on a timer; retention and off-site copies belong to a backup tool.
sinhaparth5
deleted the
14-provide-a-consistent-backup-of-a-running-instance
branch
August 20, 2026 16:00
sinhaparth5
restored the
14-provide-a-consistent-backup-of-a-running-instance
branch
August 20, 2026 16:00
sinhaparth5
deleted the
14-provide-a-consistent-backup-of-a-running-instance
branch
August 20, 2026 16:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The only correct backup procedure was "stop the server, copy the data directory, start it again". Copying it live races the metadata against the payload tree and produces a store whose rows name payloads the copy does not contain, which --fsck correctly calls corrupt. For a single binary with no sidecars, "you cannot back it up without downtime" is the gap most likely to stop somebody putting real data behind it.
Adds monobucket --checkpoint
and a console action under Settings -> Backup. The metadata goes through RocksDB's checkpoint API and the payload tree is hard-linked, so on one filesystem a backup duplicates no bytes and returns in about the time it takes to flush the write-ahead log. Restore is: stop, point MONOBUCKET_DATA_DIR at the checkpoint, start — a checkpoint is a data directory, so there is no import step.Snapshot-then-link is only half the guarantee. deleteObject unlinks its payload immediately, so a delete landing between the two passes would strip a payload the snapshot still names. StorageEngine::checkpointing_ makes reclamation a no-op for the duration; nothing leaks, because deleteObject writes the orphan record in the same batch that removes the row, so the next pass collects what the window skipped. checkpoint_test.cpp asserts this against a concurrent deleter and fails without the barrier.
The CLI form needs a stopped server — one process may open the metadata store at a time — so backing up a running instance is the console's job, because the running process is the only thing that can copy its own store. That endpoint is off until MONOBUCKET_BACKUP_DIR names somewhere it may write, and backups are created inside it under a name that may not contain a separator: the destination arrives over HTTP, and a console session is not a shell on the host. It is gated on a new Permission::BackupWrite rather than settings:write, because a checkpoint copies every S3 secret in the instance.
Nothing is scheduled. A copy is written when somebody asks and never on a timer; retention and off-site copies belong to a backup tool.