Expand description
Restore a store from a backup prefix: mushroomdb restore --from s3://….
A restore reads one restore point (W4 §3.1):
{prefix}/LATESTnames the newest manifest. A point in time (--at) uses the earliest manifest of the same lineage that holds the target commit instead; a timestamp is first resolved to a commit through the newest manifest’scommit_times.bin, over the commits the restore can see. When the instant is at or after the newest recorded time and commits with no recorded time follow, it is refused (RestoreS3Error::CommitTimesEnd) rather than placed before them.- Every file the manifest names is downloaded and its size and CRC-32
checked; its segments are checked the same way, must be of the
manifest’s generation and contiguous from offset 0, and are
concatenated into
wal.bin. The manifest, its entries and the store’sbackup.lineagefile must all name one lineage. A restore of the newest point also takes the segments of its generation shipped after the manifest, up to the last contiguous one. No manifest names those, so they are checked by their own frame checksums, size and offsets, not against an entry; a restore loses at most the segment cadence. - With
--at, the copy is cut back to the state right after the target commit (mushroomdb::restore::cut_at_commit): whatopen_atshows there, as an ordinary store. Either waycommit_times.binis trimmed to the commits restored, so the store stamps its own next commit. - The copy gets a new backup lineage. A restored store is a new history: its next backup can never resume into the prefix it came from or delete anything there (defect-ledger row 138). Back it up to a new prefix.
- The copy is opened, read-only, and must hold the commits the restore point says it does. Only then is it moved into place, with one directory rename.
Everything up to that rename happens in a staging directory beside the
target, every file fsynced. A restore that fails at any point, or a
crash, leaves the target exactly as it was — absent, or an empty
directory — never a part of a store. A failed restore removes the staging
directory; one killed outright can leave it behind, as a hidden
.<name>.restore-… directory and lock file beside the target, and the
next restore into the same target removes such leftovers no running
restore holds. A target that holds anything is refused before anything is
downloaded.
A restore on boot (crate::boot) installs in place instead: its target
is a server’s data directory, often a volume’s mount point, which no
rename can replace and whose parent may not be writable. It stages inside
the data directory, records the restore point it came from
(crate::disk::PARENT_FILE), and moves the staged files into the
directory under an install marker (INSTALL_MARKER) naming them. The
marker is removed last: a data directory holding it holds a part of a
store, and the next boot removes exactly the files it names
(undo_interrupted_install) before restoring again.
Structs§
- Restore
S3Outcome - What a restore did.
Enums§
- Restore
S3Error - Why a restore failed. The target is in every case as it was before the
restore — absent, or an empty directory. (Once the store is in place
nothing is reported as a failure; see
RestoreS3Outcome::install_note.) - Restore
Target - The point in time to restore (
--at).
Constants§
- INSTALL_
MARKER - The file in a data directory that says a restore on boot is moving a
store into it: one line per file it moves,
<name>\t<size>\t<mtime ns>, as the file was staged.mushroomdb::GraphDb::openrefuses a directory holding it. The file a restore on boot (MUSHROOMDB_RESTORE_FROM_S3) writes into a data directory while it moves a restored store into it, naming the files it moves. While it is there the directory holds a part of a store, andGraphDb::openrefuses it (refuse_half_installed). - STALE_
STAGING_ AFTER - How old an unlocked lock file, or a staging directory without one, must be before a sweep counts it as a killed restore’s. A restore creates its lock file, then locks it, then creates its directory: one younger than this may be a restore between those steps.
Functions§
- install_
interrupted - Whether
dirholds a restore on boot that stopped while it moved its files in (INSTALL_MARKER): what the directory holds is then a part of a store, and must not be opened. - restore_
from_ s3 - Restore the backup at
from(s3://bucket/prefix,r2://…orminio://…) intointo, atator at the newest restore point. - restore_
from_ s3_ with restore_from_s3over any variable lookup.- restore_
from_ store - Restore from
prefixinstoreintointo: the object-store half ofrestore_from_s3, for anyObjectStore. - restore_
in_ place - Restore the newest restore point of
prefixinto the data directorydir, in place (see the module docs), recording where it came from incrate::disk::PARENT_FILE.dirmay be absent, empty, or hold onlylost+found, aLOCKfile, an emptywal.binand the leftovers of killed restores into it. - undo_
interrupted_ install - Undo a restore on boot that stopped while it moved its files into
dir: remove the files itsINSTALL_MARKERnames, then the marker. Returns the files removed; nothing when there is no marker. Only plain file names directly indirare touched.