Mirroring A Vault
Offer a vault to a linked server, accept it, work in the copy, handle held changes, keep versions, rotate keys, delete or end a mirror.
Mirroring copies one of this server's vaults to a linked server. This server stays the vault's core; the other server (the mirror) receives the vault's keys and a full copy that follows every change. Link the two servers and give the linked server a vault role first.
Offer And Accept A Vault
Offer it, on the core
1vh vault list # the vault's number2vh mirror add <vault> --to <server>The vault is checked before anything is offered; a refusal says why and what to do (see the table below).
Accept it, on the mirror
1vh mirror pending # offers waiting here, and relink requests2vh mirror accept <offer>You will see
Offer <n> accepted: the keys come next.To refuse it,vh mirror decline <offer>; the core is told.Wait for the first copy
1vh mirror list2vh mirror info <vault>The core sends every key version the vault needs, each wrapped to the mirror's own key; the mirror proves each against the key it pinned when the servers were linked. If a single version can't be proven, the whole start is refused and nothing is written. The mirror then creates the vault with the core's vault id and copies its tree. The copy is read-only until the first copy finishes; then the state is
live.
In the web console: System › Linked servers › Mirrored vaults › Mirror a vault on the core (it asks you to confirm it's you, since the vault's keys go to the other server), and Offers on the mirror.
Unanswered offers expire after 7 days. The mirror refuses a vault whose uid or name it already has, or that would not fit on its disk.
Why an offer is refused
Offer refusals
- Cause
- The vault is mirrored already (one mirror per vault), a start is in progress, or it is another server's vault held here as a copy
- Fix
vh mirror info <vault>shows which. Cancel a start to begin another; only a vault's core can mirror it.
- Cause
- The vault is replicated through its bucket (
vh vault join) - Fix
- A vault is mirrored or bucket-replicated, never both.
- Cause
- A remote attach or detach, layout migration, key rotation or key salvage is running
- Fix
- Offer it once that has finished (
vh vault remote status <vault>for an attach).
- Cause
- The vault is deleted and waiting for its purge
- Fix
- Restore it first (
vh vault restore).
- Cause
- It still holds files in the legacy
gcm0format or unencrypted files - Fix
- Convert them first (
vh vault format status <vault>).
- Cause
- This server can't prove one of the vault's key versions
- Fix
- See Secrets And Key Export.
- Cause
- Its trash holds files deleted before 1.27.1, which a mirror can't name
- Fix
- Restore or purge them from the trash first.
- Cause
- Some files' bytes are only in the vault's bucket; a mirror gets what this server holds
- Fix
- Download them here first: open them, or set the vault's sync strategy to keep everything on disk.
Mirror Automatically
These settings are per linked server and off by default.
| Command | Run on | Effect |
|---|---|---|
| Core | Offer that server every vault not mirrored yet, and each new vault as it is created. An offer it declined, or that ended, is not made again until the setting is turned off and on. A vault the checks refuse is tried again later. | |
| Mirror | Accept every vault that server offers, without asking. With the core's mirror-all on too, mirroring needs nobody on either side. | |
| Mirror | When that server ends a mirror and asks to remove the copy, keep it here as an orphaned copy instead. | |
| Mirror | Keep versions of what the core replaces or deletes (see below). |
Turn any of them off with off in place of on. The console has them under Mirrored vaults › Per linked server ›
Settings.
Who Uses The Copy
Nobody on the mirror can use the vault until the core says what it grants. After that, the mirror's super admins get exactly the vault role the core gives the linked server, and no local role, group, admin role, vault policy or ownership gives access to it there. The vault's access list is shown read-only on the mirror, marked as the other server's. Its owner appears as an account of the other server, which can never sign in here.
Working In The Copy
While the link is up and the state is live, a person allowed to change the vault can work in it on the mirror through
the mount, the web console, uploads, vh fs put, shares and the S3 gateway: create folders and files, write, rename,
move, delete, and change a file's mode or time. They see the change at once. The core checks it, carries it out as
that person and sends it back, and both copies stay identical.
- A copy made on the mirror appears once the core has made it.
- Owners and symlinks are changed on the core only.
- A file open for writing when the link drops is kept and sent when the link returns.
- Contents that have not arrived yet are fetched in the background. Opening such a file waits briefly and then says why it can't be read (the link is down, it is still on its way, it failed); it never shows empty or wrong contents.
When the copy is read-only
While the link is down, during the first copy, while a copy is stopped, paused or switching, and for an orphaned copy, nothing can change the vault on the mirror, by anyone. Changes from the core keep arriving.
| Way in | What it answers |
|---|---|
| "Read-only file system" | |
Refused with read_only and the reason | |
HTTP 503 with Retry-After | |
Exit code 69 | |
503 ServiceUnavailable | |
| Refused |
Mirror States And Recovery says which state you are in and the way out.
Held Changes And Conflict Copies
When the core refuses a change made on the mirror (the name was taken there meanwhile, the file changed there, or the change is not allowed), nothing is lost: it becomes a conflict copy named "name (conflict ...)", or a held change. A held change puts the file back to the core's version and keeps the person's change with the reason.
| Command | Summary |
|---|---|
List held changes and conflict copies; --all includes retried and discarded ones. | |
| Send it to the core again as the person who made it (after the core's grant changed, say). If the core refuses again, it is held again. Needs the vault to be live. | |
| Save the person's version (decrypted) to a local file. Nothing in the vault changes. | |
| Drop it, or dismiss a conflict copy's record (the conflict copy stays in the vault). |
The console lists them under Held changes on the vault's mirror page, with Retry, Discard and Save their version.
Keep Versions On The Mirror
A mirror can keep the previous version of each file before the core's change replaces or deletes it there, a safeguard against an unintended deletion on the core:
1vh mirror versions <vault> on # the last 10 versions per file for 30 days2vh mirror versions <vault> on --keep-last 3 --max-age-days 0 # the last 3, however old3vh mirror versions <vault> off
--quota-bytes caps the space they take; 0 means no limit of that kind. The versions are the mirror's own (the core
never sees them), are listed with vh recovery list, and restoring one is a change made on the mirror like any other.
See File Recovery.
Rotate A Mirrored Vault's Key
vh vault keys rotate works on the core while the vault is mirrored. The core first sends the new key version to the
mirror, proven the same way as at the start, and rotates only once the mirror has it. If the mirror is not live, its
link is down or it refuses the key, nothing is rotated and the refusal says what to do.
The mirror switches to the new version when the core's changes say so and fetches the re-sealed files like any other change. The old version stays on both servers, so files still sealed under it stay readable until their new bytes arrive. Rotating on the mirror's side, and key salvage on a mirrored vault, are refused. See Encryption.
Delete A Mirrored Vault
On the core, vh vault delete asks what happens to the linked server's copy. There is no default:
1vh vault delete <vault> --mirror-copy leave # the copy stays there as an orphaned copy2vh vault delete <vault> --mirror-copy remove # the copy is removed too
Restoring the vault during the restore window lets the mirror follow again. You can change the choice until the purge
by running vh vault delete <vault> --mirror-copy <choice> on the deleted vault. To keep the files on the mirror
whatever the core does, detach the copy there before the purge.
A copy held for another server is never deleted as a vault: detach it, or remove an orphaned copy with
vh mirror cancel. See Deleting And Restoring Vaults.
End A Mirror
| Situation | Command | Effect |
|---|---|---|
vh mirror cancel <vault> | Ends the mirror at once; the other server is told (when it is reachable) and keeps its copy as an orphaned copy. | |
vh mirror cancel <vault> --remove-copy | Ends it and asks the other server to remove its copy, which it does unless it keeps the vaults this server removes. | |
vh mirror cancel <vault> | Cancels the start at any step. A copy that never completed is removed either way. | |
vh mirror cancel 0 --offer <offer> | Cancels the offer. | |
vh mirror cancel <vault> | Removes the orphaned copy and its keys from this server. | |
vh mirror detach <vault> | Leaves the mirror with the files as a vault of this server. See Detach. |
A live mirror is left from the mirror's side with vh mirror detach, never cancel.
Related reference: vh mirror, vh vault delete.
