Backup and restore
One archive holds the state root: the generation store, the databases, the secrets, and a manifest with a checksum for every file.
tadoru backup works whether or not the server is running. A restore needs it stopped,
because a restore replaces the files the server is reading.
# Write an archive. The passphrase encrypts the secrets and is not stored.tadoru backup --data-dir ./data --output tadoru-backup.tar.gz \ --passphrase-file ./passphrase
# Say what a restore will replace and what it will delete, and replace nothing.# The same passphrase as the real one, or the two see different files.tadoru restore tadoru-backup.tar.gz --data-dir ./data \ --passphrase-file ./passphrase
# Do it.tadoru restore tadoru-backup.tar.gz --data-dir ./data \ --passphrase-file ./passphrase --yesA backup beside a running server
Section titled “A backup beside a running server”Nothing has to stop. Each database is copied through SQLite’s own backup interface, which is consistent against a live one, and a generation never changes after it is written.
Each database is copied in one pass, from one snapshot. The copy holds the database as it was when
its pass began. The server keeps answering and writing meanwhile, so a busy query log does not hold
the backup up. What the server writes during the pass stays in the write-ahead log (the -wal file
beside the database) until the pass ends. The server folds it in afterwards. A pass reads the
whole file, so a large query log takes seconds to copy, and longer on a slow disk.
The backup needs free space while it runs:
-
In
$TMPDIR, where it stages all that goes into the archive:- For each database that it copies: the size of its file and of its
-walfile together. Pages that are only in the-walfile go into the copy too. The databases arecontrol.sqlite,auth.sqlite, the query logtelemetry.sqlitewhere the archive carries it, and the serial witnessserials.sqlite. - The size of each revision of the configuration that it carries, at most
the
generationsdirectory of the state root. - With a passphrase: the size of the secrets, which it stages sealed. Add the size of the copy of
auth.sqliteonce more, its file and its-walfile together, for its sealed copy beside the plain one. Each sealed file is 40 bytes larger than what it seals.
Where
$TMPDIRis in memory, such as atmpfs, all of it takes memory. - For each database that it copies: the size of its file and of its
-
Where the archive goes: the size of the archive, beside the old archive until the new one replaces it.
-
On the disk of the state root: room for what the server writes during the copy. That stays in the
-walfiles until the copy ends.
Where two of these places are on one file system, add their sizes.
Until the new archive is renamed onto the output path, the archive that was already there stays as
it was. After the rename, the output path holds the new archive, whole. A backup that is killed
before the rename can leave its staging directory and a .partial-<number> file behind, as the end
of this section says.
A backup beside a running server differs from one taken with the server stopped, and the output says so. With the server stopped, the archive carries every revision on disk. With it running, the archive carries the revisions whose content is what was recorded for them. A revision can be half written at the moment the copy passes it. Such a revision is left out. The line reads like this:
taken beside a running server, carrying 4 revisions of the configuration. One it left outis one a restore of this archive cannot roll back toA revision goes in whole or not at all. The server deletes old revisions as changes land, so a copy can start on a revision that is going away. Such a revision is left out rather than half carried, because a restore refuses an archive that holds half of one. The count above is the count in the archive. A second line names the rest:
2 more changed while this ran and are not in the archive. The server deletes old revisionsas changes land, and a revision this leaves out is one a restore of this archive cannotroll back toThat is not a problem with the archive. It says that the reach of a rollback after a restore of it is two revisions shorter.
One case ends the backup instead of leaving a revision out. A revision deleted in the middle of being copied can stop the copy. Nothing is written then. The message names the revision and says to run the backup again.
Both archives restore, and both give a server that starts. The difference is how far back a rollback can reach afterwards.
An older build could write a revision that records a file under a name that the config root
skips, such as .notes. A backup, with the server running or stopped, carries that revision with
its history. It says on a line of its own that a rollback to it is refused, with the words of
that refusal. A restore of the archive does not change that:
revision 2 is in the archive with its history, and a rollback to it is refused, after arestore too: generations/2/.notes, setting generation: has a name that starts with `.`, ...An older build could also take a forwarder under onion with addresses, such as
tls://resolver.onion (192.0.2.1). This build refuses one in a new configuration. A restore of
an archive whose active configuration holds one goes on. That configuration is read as the one
that runs. The restore prints a line for each such entry before it replaces anything, in its
preview and in its run:
warning: generations/7/server.toml, setting forwarders[0], entry tls://resolver.onion: a forwarder under onion with addresses is served as before, and its addresses go past Tor. The next change of the configuration is refused until the entry is taken out, so take it outThe server then starts with it, and logs the same warning at each start (A forwarder under onion with addresses). The next change that keeps the entry is refused, so take the entry out. A generation of the history that holds one restores too, and a rollback to it is refused.
A backup beside a running server holds prune.lock in the state root while it copies. That
lock keeps the prune of a journal out of the copy. Where the server prunes a journal
at that moment, the backup waits for the prune to end. The server makes the file at its start,
so a backup beside a running server refuses where the file is missing. A backup with the server
stopped needs no such lock.
A backup also holds pki/self-signed/lock while it lists and reads the store of the certificate
that the node makes, with the server running or stopped. A change of that certificate holds the
same lock. Such a change is a new certificate, or a renewal and the removal of the old one after
it. So one waits for the other, and the archive holds the store as it was at one moment. Where a
change holds the lock, the backup waits for it to end, and says so on a line of its own:
a change of the certificate that the node makes holds /var/lib/tadoru/pki/self-signed/lock. Thebackup waits for it to finishThe wait is short, because a change writes a few small files. A change waits for a backup at most 30 seconds. A revision that writes a new certificate in that time is refused as busy. It applies once you send it again.
The commit of a revision never waits for a backup. It leaves its new certificate for the renewal task, which tries every minute, and the old one serves meanwhile. So a backup that is stopped part way, as with Ctrl-Z, holds new certificates off until it goes on or ends. It holds nothing else of the server.
Beside a running server, a store with no lock is refused, because nothing then holds it still.
The server makes the file when it changes the store. A backup that finds one of these replaced or
moved while it copies writes nothing and says to run it again:
- A file of the store.
- A directory in the store.
- The store.
pki/.lock.
No archive carries lock. A name in pki/ that spells self-signed in another case, and that is
not the store, is left out of the archive, with a line that names it.
A backup that fails changes nothing in the state root and removes what it staged. The archive is
renamed onto its name only once it is whole. A backup that is killed, as with Ctrl-C or kill -9, can leave two things behind:
- A
.partial-<number>file beside the name of the archive. - Its staging directory in the temporary directory of the system (
$TMPDIR, often/tmp). It is named.tmpand six more characters, with mode 0700, of the user who ran the backup.
That directory holds plain copies of the databases, auth.sqlite included, and the sealed
secrets, so delete both.
The archive is written outside the state root, and a path inside it is refused. The backup reads that path once, at its start. Run it as the user of the server, as the restore. It does not guard against another writer that swaps a link into the path of the archive while it runs.
What is in the archive, and what is not
Section titled “What is in the archive, and what is not”A database goes in through SQLite’s own backup interface rather than as a file copy. A copy of a live database is missing whatever is in its write-ahead log.
So an archive holds no side file of a database: no -wal, -shm or -journal beside a .sqlite
file, outside generations/. A restore refuses an archive whose manifest names one, in any case. It refuses an
archive that unpacks one that its manifest does not list, too. Both refusals come before it opens
any database of the archive. A planted log beside a database would be read over it, with the rows
of another store.
These rules hold for the names in an archive:
- A file of the config root keeps its name under
generations/, whatever it is, since no database opens there. - Outside
generations/, every name in an archive is ASCII. - Beside its state root, an archive holds its manifest and nothing else.
- A restore refuses an archive that holds a link, since no backup writes one.
The restore unpacks the archive into a directory that only its own user can enter, whatever modes
the archive gives. Before a restore puts a database in place, it deletes the -wal, the -shm and
the -journal of that database here. So no page of the store that was there is read over the
restored one. Where one of those names is no file, such as a directory, the restore refuses before
it replaces anything, and the preview names it.
The configuration files you edit are not in it, and that is deliberate. The generation is what the server runs. The config root is a copy of it that you can edit, so a restore writes that copy from the generation it put back. An archive that carried both would restore an edit nobody adopted, and then adopt it.
The archive carries a copy of the serial witness, serials.sqlite, under
witness-copy/serials.sqlite. It is copied after the generations, so it holds a row at or past each
serial that a carried revision serves. A restore merges it into the witness of the node. It puts
no file of it in place, as The serial witness says. Where the file is no
witness that a restore can read, the backup leaves the copy out. It says so on a line of its own.
A state root with no serials.sqlite gives an archive with no copy.
The query log is left out unless --include-telemetry asks for it. It is the one an
operator sometimes wants and never needs. A backup carries the query log only from the state root.
- Where
telemetry.placenames the runtime root, the query log is in memory. The archive carries none, and the backup says so. The files of the query log in the state root are then an old copy, which no archive carries as the log. - Where
telemetry.placedoes not read, the place is not known. On the disk the log still runs in the state root, and no backup carries it until the file is reset. - A query log in memory is the one of
telemetry_storage = "memory". A restart of the packaged service keeps it, a reboot empties it, and no archive ever holds it.
An archive holds the query log as the backup’s copy of it ended, which is before the backup writes the archive. The copy starts again when the log changes under it, so a copy that a redaction overtakes ends with the cleared log. A copy that ended before the redaction holds the values that the redaction cleared, even when the archive ended after it. A restore of that archive brings them back. Delete such archives, or redact again after the restore.
When the scrub of a redaction ends, no free page of the query log holds a value that the redaction
cleared. The log says the query log gave back its free pages and cut its write-ahead log, and
dns_querylog_scrub_pending reads 0. That holds for the file at that moment, not for later. The
unused space inside the pages in use can still hold copies of cleared values. A prune after the
scrub can free such a page with its copy in it, and that prune owes no new scrub. So start the
backup soon after the scrub ends. The copy can still hold cleared values in the unused space of its
pages in use, and in a page that a prune freed since.
What a redaction clears from the file says
what a redaction clears.
A restore puts the query log of an archive only into the state root. Two cases differ.
- The restored configuration keeps the query log in memory. The log of the archive stays in the archive, and the query log here stays as it is. A store in memory keeps its rows and runs after the restore.
- The query log runs in memory here, and the restored configuration keeps it on the disk. The restore puts the log of the archive in the state root. The store in memory stays as an old copy, which the server reports and never deletes.
In the second case the restore says what the next start reports of the old copy. It can say that a copy can still be at its old path, with no directory. That holds where the runtime root is missing or was swapped in this boot. It names an older copy in memory whose record it ends, since the record keeps one old copy only.
That restore refuses before it changes anything in these cases:
- The state root holds a file of the query log already, an old copy of an earlier change. Remove those files by hand, and run it again.
- The store in memory is, holds or sits inside the state root, since the server could not report it as an old copy then.
- A rewrite of the query log left a file aside in the state root. This holds for a restore that puts the log of the archive there.
telemetry.place.newstands as no file. This holds for a restore that writestelemetry.place.
Where telemetry.place does not read, the log of the archive stays in the archive, and the restore
says so and goes on.
A query log from an older build is upgraded on the copy in the staging directory, a temporary
directory under TMPDIR that the restore removes. Where that fails, the restore goes on and prints
a note. The first two notes name the staging directory: it had too little room, or the upgrade did
not finish with an error. The others say that the open failed, or that this build cannot read the
file. In the first cases the file is whole at the last step that committed. The restored server
tries the upgrade again at its start. Where the restore cannot fold the staged log into one file, it
stops and replaces nothing. Troubleshooting lists the notes.
An archive holds auth.sqlite as the backup’s copy of it ended, and that copy comes before the
archive is written. The archive keeps what a later change removed: a removed account, an old
password, a session that ended or a revoked token. That holds also where the archive ended after
the change. A change before the copy left no verifier in the space that it freed, so the archive
holds none either. The unused space inside pages in use can still hold old copies, as
What a removal leaves in the file says.
The cache snapshot, cache/snapshot.bin, is never in the archive. It is a copy of answers that the
server fetches again at no cost. A restore does not touch the file. The next start loads it only
where the part of the configuration that decides an answer did not change after the write. So a
restore that changed that part starts with an empty cache.
Each list file of a source with a path is in the archive, an uploaded list included, because it
is a file of the generations. The compiled set of each source, blocklists/<id>.bin of the state
root, and the body beside it are not. After a restore, the first pass compiles each list file again
from the generation that runs, with no request to the network. A source with a URL waits for its
host.
The copies of overwritten edits, in overwritten/ of the state root, are never in the archive.
They are the text of saves that a change wrote over, and they belong to this machine. A restore
neither replaces nor deletes them, so they are still there after it. projected.toml, the record
of what the server wrote into the config root, is never in the archive either. A restore refuses
an archive that names either one, in any case, so a crafted archive cannot replace them.
pending-lists.toml, the record of the lists that a change of files still owes, is never in the
archive. A restore does these things with it:
- It deletes
pending-lists.tomlandpending-lists.toml.new, under its mark and at each run. - It keeps each copy set aside.
- It refuses an archive that names one of them.
Each refusal of a name of the machine covers two things. One is a name of the manifest. The other is a file that an archive unpacks and that its manifest does not list. Troubleshooting says what they are and how to delete them.
record_times.sqlite in the state root is the store of the time at which each record of a zone
last changed. Each machine keeps its own times, from the changes that it saw. It is never in the
archive, and its side files are not either. The server writes the store after each change of the
records of a zone.
A restore with --yes deletes the file, then its -wal, its -shm and its -journal, before it
replaces any other file. After the restore, every record shows no time until it changes again:
GET /api/zones/{id}/records gives it no modified_at. The preview lists them first under this deletes. Where one of these names is no file, such as a directory, the restore refuses before it
replaces anything, and the preview names it. Where a restore stopped, a run of the same archive
deletes them again. A restore refuses an archive that holds one of these names in any case, in its
manifest or not. That includes a copy that a start moved aside.
The root keys file, trust-anchors.toml, is never in the archive either, and a restore leaves
the file of the machine as it is. The root can withdraw a key because somebody else holds it. A
copy from before that withdrawal trusts the withdrawn key again. So each machine keeps the keys
it tracked itself. A restore onto a new machine starts from the root keys built into the server
there.
The passphrase
Section titled “The passphrase”A passphrase encrypts the secrets. Give one, and the signing keys, the node key and the credentials database travel encrypted. Leave it out, and a state root holding signing keys is refused, so those never leave in the clear.
A server that gets its certificate through ACME holds the key of its account and the key of its
certificate under pki/acme/. The server writes the account key when it starts its first order,
whether the order works or not. From then on, a backup without a passphrase is refused.
The archive holds whole the certificate that pki/acme/current names, also where a renewal runs
during the backup. Where the copy of current names no certificate that the copy holds, the backup
says so and carries that copy as it is. Where the store changes during each of five tries, the
backup is refused and writes no archive, so run it again. This rests on the server alone writing
pki/acme/.
A server that holds a secret of its own, or that makes its own certificate, has two more places that the backup seals:
secrets/node/holds the secrets of this node, such as the password of a PKCS #12 file.pki/self-signed/holds the key and the certificate that the node makes for itself.
Once either exists, a backup without a passphrase is refused, as for pki/acme/. A restore puts
them back only with the passphrase, as files of mode 0600 in directories of mode 0700. Without the
passphrase, secrets/node/ and pki/self-signed/ stay sealed in the archive, and the restore
writes neither. No command carries them to another node, so an archive is the only way they
travel.
The archive holds the certificate that pki/self-signed/current names when the backup runs. A
change of the certificate can fail part way. It can leave current naming the new certificate
while the server still serves the old one, and the next change puts the old name back. A backup in
that moment carries the new name, so a restore of it serves the new certificate. It keeps the old
one as the one before it. Compare the fingerprint after such a restore.
A restore of an older archive can put back an older password beside a PKCS #12 file that changed since. Once the server reads a PKCS #12 file, the start then fails, because the file does not open with that password.
The credentials database is the one exception. Without a passphrase it travels in the clear, because a backup nobody can take is a backup nobody has. It holds password verifiers and token hashes, not keys.
A passphrase also signs the archive. The backup writes a MAC over the bytes of its manifest, which holds the size and the checksum of every file, plain or sealed. A restore with the passphrase checks the MAC before it unpacks anything. Then it checks each file that it unpacked against its size and its checksum in the manifest. So nobody without the passphrase can change a configuration file, a database or a secret in a way that the restore takes.
Every restore, with a passphrase or without one, also refuses two things. One is a file or a directory that the manifest does not list. The other is an entry of a kind that no backup writes, such as a link or a sparse file.
Where the MAC does not match, the refusal says the passphrase is wrong, or the archive changed after it was written. The check cannot tell the two apart. Other changes get a refusal of
their own, such as a file whose checksum does not match.
What the MAC does not cover:
- An archive without a passphrase has no MAC. Somebody who can write where it is kept can change it, and a restore takes the change. Give a passphrase, or keep the archive where only you write.
- A restore without the passphrase checks no MAC, and says so.
- An older archive of the same passphrase passes in place of a newer one. The restore names the revision and the version of the archive first, so read them.
- The MAC does not cover how the archive is packed. That is the order of the files, the end of the stream, or a second entry under the name of a listed file. A later entry under the same name replaces the earlier one as the restore unpacks. The file that is left must still match its checksum.
The key costs 64 MiB of memory and three passes of Argon2id, once for each backup and once for each restore. That takes about a tenth of a second on a server. On a small board such as a Raspberry Pi it takes up to a few seconds. The archive records these settings.
A version before the MAC wrote archives with no MAC. A restore with the passphrase refuses such an
archive until you add --without-mac. Somebody who removed the MAC of a newer archive would make it
look the same. Use the flag only for an archive whose origin you know. It never passes a MAC
that an archive carries.
A passphrase comes from a file rather than an argument. An argument is in the process list and in the shell’s history.
What a restore does
Section titled “What a restore does”A restore checks the MAC of the archive first, where it has the passphrase. It then stages the
archive and checks every checksum. It reads the configuration inside the archive’s generations
with the server’s own reader, and it opens the control database and the credentials database. So a
configuration or a schema that this build cannot read is refused before anything is replaced. So is
a secondary zone in the generation that the restore makes active, with setting kind, because this
build reads the kind and serves no secondary zone yet.
A zone frozen on this machine refuses the restore with the name of the zone and
tadoru zone thaw. The archive carries no journal, so the freeze would stay over the restore while
the restored revision serves other files. Thaw the zone, then restore. The preview shows its plan,
then names each frozen zone and when --yes refuses the restore for it.
The preview judges the serial witness and each frozen zone over scratch copies of the stores. The
copies are in the staging directory of the restore, a folder under TMPDIR. The preview can fail
to write those copies, or find no room for what it writes on them. Then it says that it could not
judge them, and names each frozen zone from its journal. --yes makes no such copies. Free space
on the disk of TMPDIR, or run the preview with TMPDIR on a larger disk, to see what --yes
does.
A preview with no copy of the ledger also judges no stub zone. This happens where it could not
write its copies, or where the serial witness refused before the copy was made. It then names each
stub zone of the running configuration that has a journal file here. --yes refuses the restore
for such a stub where the restore changes it. A stub whose only trace of a journal is in the ledger
gets no line, because the preview opens no database of the node.
A stub zone of the running configuration can hold the journal of a primary zone. Such a stub
refuses a restore that changes it, or makes it a primary zone. The restore says is a stub zone that holds the journal of a primary zone and what it found, before anything is replaced. The archive carries
no journal, so the journal would stay under the restored zone. Delete the stub first, in one of two
ways. Start the server, delete it with tadoru zone delete, and stop the server. Or, with the
server stopped, roll back with tadoru config rollback to a revision that does not hold it. Then
restore.
A restore that cannot tell which zones of the running configuration are such stubs is refused too, with the reason. A restore that removes the stub, or holds it as it is, goes on. A stub over a journal that ends in a freeze gives a warning there, because no thaw takes a stub. A run of a restore that did not finish, with the same archive, makes these checks a warning. Its first run made them before its mark, and the server does not start until the restore ends.
A frozen journal that no thaw of the running configuration takes stays over the restore as it is. Three kinds are such:
- A journal of a zone that the running configuration does not hold.
- A journal with a damaged frame after the freeze.
- A thaw that waits for the next start.
The restore holds each such journal to the serial witness after it. The witness holds a serial for the apex of its zone. Where that serial lies too far past the freeze for a thaw to pass it in one step, the restore is refused with the way out that the zone allows here. A thaw, a cut and a statement take a primary zone of the running configuration alone. The way out depends on the zone:
- For a zone that is not here, or that runs as a stub, the way out is an archive that does not hold it. The other way out is a primary made at its id first with the server running. The restore run again then names the way out of a primary.
- For a primary zone, the way out is the thaw. For a damaged journal it is the cut, the statement of the freeze, a start and the thaw.
A journal that does not say whether its zone is frozen, such as one that does not read, refuses the
restore too, wherever the apex of its zone has a row in the serial witness after the restore. With
the server stopped, run tadoru zone journal cut or tadoru zone journal remake. Then run
tadoru zone journal settle-freeze with --not-frozen, or with --frozen-at <serial> where the
zone was frozen. Then restore. For a zone that is not here, or that runs as a stub, the way out is
the one of the list above. Each refusal names the zone, and comes before anything is replaced.
A restore reads each journal file of the state root to find a freeze. It reads only a regular
file, and it follows no link at the journal, at the folder of its zone or at zones. A named pipe,
a socket, a device or a link in the place of a journal refuses the restore with its path. Put the
journal file itself in that place. Where what stands there is no journal of this node, move it
away. A link at the folder of a zone or at zones refuses the restore too: put the folder itself
there. This check comes before every other check of the journals and before anything is replaced,
and the preview names this refusal alone. Then restore.
A frozen journal inside the reach of a thaw gives a warning, and the restore goes on. The warning says whether the restored revision holds the zone of the journal.
- If it holds the zone as a primary zone, the start after the restore reads the journal. A damaged
journal stops the zone. A whole one serves the zone frozen where the restored
ledger holds the history of that journal, as in an archive taken after the
freeze. Else the start stops the zone until
tadoru zone journal settle-freezestates its freeze. - If it holds the zone as a stub zone, the start serves the stub, which reads no journal. The journal stays, for a primary zone made at that id.
- If it does not hold the zone, the journal stays, for a zone made again at that id.
A thaw that waits for the next start belongs to the running revision, which the restore replaces.
A revision that a thaw made records that thaw, and the archive carries no journal. A machine that
holds no journal of the zone, such as a new one, takes such an archive, and no thaw waits after the
restore. Its start stops the zone as for any journal that is gone, until tadoru zone journal settle-freeze states its freeze. Then the zone serves its restored files.
Where a journal of the zone is here and does not hold that thaw, the restore is refused before anything is replaced. The server could not record the revision of the restore after its files. Where the thaw waits for the next start on this machine, start the server first, so that it appends the thaw, then restore. Where a start cannot append it, such as after a damaged frame or for the thaw of another machine, take one of these ways:
- Restore an archive of a revision made after that thaw.
- Restore an archive of a revision from before it.
- Restore onto a machine with no journal of the zone.
An older build did not check this. Its restore stopped after its files, with its mark, saying
the files are restored and the revision could not be recorded. Keep that server stopped, and do
not delete restore-unfinished by hand: a start would then take the configuration files from
before the restore as edits. A run of the same archive with this build says the same and changes
nothing more. A later build adds a way to finish such a restore.
A restore also compares the files of one generation against each other. A group that names a source
that blocking.toml does not define is refused here too, and nothing in your state root is
touched. Troubleshooting has that refusal and the way out.
An older build could write a revision that records a file under a name that the config root
skips, such as .notes or notes~. The restore says so on a line of its own, with the
revision it records, which leaves that file out. A file at that path in the config root is left as
it is, and none is made where there was none.
A restore of a revision with enabled = false in blocking.toml says on a line of its own that
blocking is off for every client. The server warns of it again at its next start.
An older generation of the archive, which a rollback can make active again, is checked with less than the newest one:
- A
[[forward]]or a stub zone can sit below a cut that its zone files lack. This does not refuse it, because an update can have added that cut to the journal of the zone. - Its stub zones are not checked against its zones.
- The rules of an ANAME that read
node.tomldo not run for it.
A later rollback to such a generation checks the whole generation against the zones as they are then. It can refuse it, because the archive carries no journal.
An http_trust, an api_trust or a proxy_protocol_from can hold every public address of a
family in its allow entries, such as ["0.0.0.0/0"] or ["2000::/4"]. An older build took them.
Such a generation is not refused for it either. The generation that the restore
makes active is refused for it. So is a later rollback to the earlier generation, with the message
that A list of proxies the server will not take
gives. A refusal of a generation of the history names it, such as generations/4/node.toml.
An archive from before the upgrade that refuses a path the config root skips is taken the same
way. Its earlier generations can hold a source whose path, such as .local-list, names a file
that no revision holds, and the restore takes them. A later rollback to such a generation is
refused, with words that say to choose another revision. The generation that the restore makes
active is refused for it, naming generations/<revision>/blocking.toml. Before you take a backup
for such a restore, make the change of
A blocklist this server will not take
as one revision.
Then the preview says what the restore will replace and what it will delete, and replaces nothing.
--yes is what makes it write. Read the deletion list. A file in your state root that the archive
does not have is a file the restore removes. So is a directory that the archive does not have,
such as that of a revision after the archive’s. The preview names those directories after the
files. A restore of an older archive over a state root with later revisions then finishes. The
revision that records it is the one after the last revision of the archive.
A directory that would go can hold an entry that is neither a file nor a directory, such as a link.
That stops the restore before it writes anything. The preview names it under this cannot remove. The restore
removes and writes each file relative to a directory it opened, and follows no link.
Right after it takes the state root’s lock, a restore takes auth.gate and auth.lock in the
state root. A preview does too. Each holds them until it is done. An accounts command holds the lock
while it runs, and refuses while a restore holds either. So no account changes while the restore
can replace auth.sqlite. Where an accounts command runs, the restore waits for it, and says so
on standard error. A new accounts command is refused while it waits.
A retry of a restore that stopped needs the passphrase file of the first run, where the first run had one. A run without it would leave the credentials and secrets that the first run had not reached.
With --yes, a restore takes prune.lock in the state root before it writes anything, and holds
it until it is done. A backup that started beside the server and still copies holds that lock.
The restore waits for the backup to finish, and says so on standard error. The restore keeps
prune.lock in place. A preview takes no such lock.
A preview is not a read-only command. It makes the three roots if they are absent. It
takes the state root’s lock. It makes the empty auth.gate and auth.lock where they are
missing. So a preview against an empty path leaves the directories behind.
Run a restore as the user of the server, with the server stopped, as tadoru zone export runs.
The files that a restore writes belong to the user that runs it, and the server cannot open files
that root owns. So a restore as root over a state root that another user owns is refused. A
restore follows no link that is in the state root, and no link put in place of a directory that
it opened. It does not guard against another writer in the state root or its parent while it
runs. A restore as the user of the server, with the server stopped, has no such writer.
Before its mark, a restore holds control.sqlite, control.sqlite-wal and control.sqlite-shm
of the state root each to a regular file with one name, or to no file. There are three reasons:
- A link sends each open and each write of the ledger to the file it names, outside the state root.
- A file with a second name is one file under both names, so a write here changes the file under the other name too.
- A directory, a pipe or a device at that name is no ledger, so a restore can neither keep it nor replace it.
Troubleshooting has the message of each.
After it writes, the restored configuration becomes a revision of its own, which is also what writes your config root.
A zone that took dynamic updates keeps them in its journal, and the archive carries no journal. So the revision of a restore cannot say which updates the restored files hold. It lists such a zone in two cases:
- The archive’s revision marked or listed it.
- Its journal ends short of what the restored
control.sqliteknows, or is gone, as on a new machine.
A listed zone serves the records of the restored files and takes no update. Every update in its journal that the restored files do not hold is gone from it. On a new machine such a zone has no journal at all, and it comes back in two steps:
- The first start stops the zone with
freeze-uncertain, because its journal is gone and it can have held a freeze. Stop the server, runtadoru zone journal settle-freeze <zone-id> --not-frozen, and start the server again. - The zone then serves its files, and its reason is
the journal is missing, and the revision lists the zone as unmarked. It takes no checkpoint and no update. Stop the server, runtadoru zone journal remake <zone-id>. Then runtadoru zone journal settle-freeze <zone-id> --not-frozenagain, because the remake cannot read the journal that it replaced. Start the server.
The zone then serves its journal and takes updates again. A zone at its files keeps a record past its expiry time until then, because the expiry sweep passes over it. A rollback reads a zone with updates the same way. A zone that answers SERVFAIL, or takes no update says what each state of a zone means.
A server that answers DNS-01 adds a TXT record for each challenge, and removes it after the
order. pki/acme/challenges.toml lists each such record until its removal commits. The
control database keeps the add of each one. The archive carries both, each as it was at its own
moment, so at its end a restore holds them to each other:
- A record that the control database still holds and the file does not list gets a line. The server then removes it, or finds it gone.
- A line whose add the control database does not hold goes. Its record is listed.
- Each other TXT record at the name of a challenge in
acme_namesis listed too. One example is a record that a checkpoint of the zone wrote while a challenge stood.
A listed record can be yours, or another ACME client’s. So check each one before you delete it. The restore deletes none of them, and a start lists nothing. The list reads the zone files that the restore put back. It does not read the journal of a zone, so a record that only a journal holds is not on it.
Without the passphrase, pki/ stays sealed in the archive, so the lines on this machine are held
to the restored control database instead.
Without the passphrase, a restore does everything else. It leaves the sealed secrets alone on disk, and says how many stayed in the archive.
A restore that puts the credentials database back ends the sessions the archive carried. A session is a cookie one server issued, and the machine you restore onto never issued it. The accounts stay, because carrying them is what the archive is for.
A restore without the passphrase leaves that database alone, so the accounts and the sessions you have now are the ones you keep.
control.sqlite keeps the stored answers of changes of records through the API, apart from the
commands of those changes in the audit. A restore puts back the stored answers of the archive and
closes them at once, whatever their time. A settled answer of the archive is never sent again for
its key. A change of the archive that was still pending never replays its answer. The commands
of those changes stay in the audit by its own rules.
Closing the answer of a key is not the end of its change: a change of the archive that was still
pending stays pending after the restore. The archive carries no journal, so the restored
configuration does not read the journal of the change, and nothing says whether it landed. Its zone
takes none of these until a later build of this server settles the change: an update, a change of
records, a checkpoint, a freeze and a thaw. tadoru health names the zone and the change.
An archive that carries no control.sqlite keeps the one in the state root. The restore closes
the stored answers of that one the same way. A restore refuses an archive whose stored answers it
cannot close, before it replaces anything.
After a restore, a request of POST /api/zones/{id}/records under a key of the archive answers by
what the archive kept for that key:
- A settled answer, a
200or a refusal of404,409,422or500: the key is new. The request runs again against the restored zone, and answers what that run gives. AnIf-Matchread before the restore is usually409version-moved, because the restored zone has no journal. - A change that was still pending: its zone is held. A request of that zone answers
503unsettledwith the command, until a later build settles the change. The same key with other lines answers503recovery-owed, which says that a restart does not clear it. - A
429or a503: the archive kept nothing, so the request runs as a new one.
The commands of dynamic updates, of ACME, of aging, of serial witness moves and of expiry sweeps in
control.sqlite carry a stamp. The server writes it after a command finishes, and deletes the
command by it. A restore brings the stamps of the archive, or none from an archive of an older
build. The first start after a restore deletes none of those commands in its first 7 days and 1
hour. It stamps the commands that have no stamp, up to 1,000 a batch from its first batch on. Each
command then waits 7 days and 1 hour from its own stamp. The start brings each stamp that is ahead
of its own clock back to that clock. So a repeat of an id still gets its first answer for at least 7
days. An archive with no control.sqlite keeps the ledger here, with its stamps.
The serial witness
Section titled “The serial witness”A secondary server follows a zone by its serial, and takes a serial only where it is ahead of the
one it holds. The serial witness, serials.sqlite, holds the first and the last serial that each
apex served on this node, so that no serial goes back. It belongs to this node, so a restore never
replaces it. The restore merges the copy of the archive into it, row by row:
- An apex with no row here takes the row of the archive.
- An apex whose rows share one first serial keeps the last serial that is ahead.
- Two rows with another first serial meet two histories of one apex, and only you can say which
one its secondaries follow. The row keeps the first serial of this node. It stops its zone with
witness-fenceduntiltadoru zone witness acceptorraise. - A row whose zone stops with a fence or with the mark of a spent history keeps that.
- Each apex keeps the later of the two whole-zone times. That is the time until which this node
answers an incremental transfer with the whole zone. The apex also keeps the old serials of both
sides. These are the serials that its zone must serve past first, as the shortest range that
holds both. An archive from a build before this one does not know its old serials, so its apex then
waits for
tadoru zone witness raise. - A whole-zone time whose deadline passed comes in from the archive while either side holds a row of its apex.
The revision of the restore then judges each restored zone against the merged rows, as a start
does. A zone backed up at serial 100 that served 105 since comes back at a serial past 105, with
the records of the archive. The preview with no --yes prints what the merge would change: which
zone moves to which serial, and which zone stops and why. It changes no file of the witness,
because it runs on copies of control.sqlite and serials.sqlite.
On a new machine, with no witness of its own, the restore makes one with the mark of a lost
history. So each restored zone comes in fenced, and answers SERVFAIL until tadoru zone witness accept or raise with the server stopped. The machine cannot tell which serials the secondaries of
the old one hold. Read them with dig soa @secondary <apex>, and raise an apex where a secondary
holds a serial ahead of the zone. An archive of a node whose witness was lost carries that mark,
and a restore keeps it. An archive with no copy, from a build before the witness, onto a node with
no witness and no mark, makes none. The next start is a first start, which starts the history of
each zone at the serial that it serves.
Before its mark, the restore reads the witness of this node. It settles each command of tadoru zone witness that did not finish, and runs the merge on a copy, so a refusal replaces nothing. After
the files are in place, it merges the copy. A merge that refuses then leaves the mark of the
restore, and the same archive run again takes it up.
A restore that the serial witness refuses
lists each refusal and its way out.
The serial witness holds for the commands of this server alone. Do not copy, edit or roll back
serials.sqlite by hand. Use tadoru restore. Two losses go round it, and the witness cannot see
them:
- A copy of
serials.sqlite, old or from another node, put into place by hand. It reads as valid, and misses what this node served since.tadoru restorebrings a copy in the supported way. - A snapshot of the whole state root put back, by a VM or a file system such as ZFS. It takes
control.sqlite, the journals and the witness back together, and each zone goes back with no word.
Notes, expiry times and the way back
Section titled “Notes, expiry times and the way back”The comment and the expiry time of a record are in the archive where the files of a generation
hold them. A note that the journal took after the last checkpoint is not in the archive. A restore
loses it, as it loses an update after the last checkpoint. Run tadoru zone checkpoint <zone-id> before a backup to carry the notes of the journal too.
A restore keeps the aging.clock of the state root that it writes, the file of the
zone clock. It puts none of the archive in its place. So a restore onto a
state root with no such file, such as a new machine, starts with none. Where a zone has
record_expiry, the server then holds the zone clock until tadoru zone clock resume, and no
record expires until then. A restore over a state root that has the file keeps it, and the clock
runs.
A zone that a restore lists serves its restored files and takes no change, and the expiry sweep passes over it. So a record past its expiry time stays until the zone serves its journal again, as the way out of its reason says. Troubleshooting names the way out of each reason.
Going back to an older build
Section titled “Going back to an older build”An older build does not run on the state root of this build. This build writes schema 24 of
control.sqlite, and a build before schema 24 refuses its control.sqlite at the open, and names
both versions. An older build also refuses the new settings of zone.toml, and reads a journal frame
with notes as damage. So the way back takes the older binary and a fresh state root:
- Stop the server of this build. Move its state root aside, and keep it unchanged.
- Install the older binary.
- With the older binary, restore an archive that the older build made. Restore it into a new, empty state root and a new, empty config root.
- Start the older server on the new roots.
The restore loses each change after that archive. The older restore refuses the state root of this
build, because its control.sqlite is newer, so step 3 needs the new roots. The journals of the
state root of this build stay in it, apart, and no build reads them. Each zone that took updates
comes back as on a new machine.
A build of schema 24 from before the merge of a zone file opens the state root of this build,
because the schema is the same. It cannot read some of the rows that a merge wrote: a pending,
applied, unchanged or refused merge. A pending or applied merge stops every zone at the start. A
change of records under the key of an unchanged or refused merge answers 500 row-unread. That run
then holds every zone until the next start. Such a build has no merge route, so a change of records
is how a key meets it. So take the same way back for it: a fresh state root, never the one of this
build. Nothing refuses the root of this build to that build, and its restore does not either, so
step 1 is yours to keep.
A build from before allow lists is also a build before schema 24, so the same way back holds. Such
a build does not know action of a source or enabled of blocking.toml, and holds each file of
the config root to 4 MiB. You can take the configuration of this build along, rather than the one of an older archive. While
this build runs, first make the changes that
blocking.toml: the lists this server blocks from
names for an older build. Then start the older build on a copy of the config root with a new, empty
state root. That start is a first start: the accounts, the history of revisions and the rest of the
state root of this build stay behind.
After a restore
Section titled “After a restore”Start the server and read GET /api/health, which says the revision it is running. GET /api/revisions says what the restore became and what came before it.
A restore that replaced the credentials database ends every session, so everybody logs in again. API tokens from the archive keep working, because a token belongs to an account rather than to a machine.