Mirror States And Recovery
What each mirrored vault state means on the core and on the mirror, whether people can write, and the way out of each - resync, switch, take over, detach.
Every mirrored vault has a role on each server (this server is its core, or holds a copy) and a state. Find the state, read what it means on your side, and take the way out in the last column. Nothing on this page deletes a file: every way out keeps what either side wrote, as held changes, conflict copies or the core's trash.
1vh mirror list # every mirrored vault: role, linked server, state2vh mirror info <vault> # one vault: state with its reason, link, position, held changes, and what to do next
vh mirror info ends with the server's own advice when the vault waits on something. The web console shows the same
under System › Linked servers › Mirrored vaults: the state in plain words, What to do, and only the actions
that fit.
States
The first column is the state vh mirror list and vh mirror info print; the second is the console's label.
| State | Console | What it means | Writable | Way out |
|---|---|---|---|---|
| Live | Both copies match. On the mirror, changes go to the core first and come back once it accepts them. | Yes, on both | Nothing to do. | |
| Live, link down (core) · Read-only: link down (mirror) | The link dropped. The core keeps working and catches the mirror up when it reconnects. | Core only | When the link drops. | |
| First copy | The mirror is copying the core's tree; vh mirror info shows how far it is. | Core only | Wait, or vh mirror cancel <vault> to stop the start. | |
| Paused | Following is paused, with the reason; most often because the core is deleting the vault. | Core only | See The core is deleting the vault. | |
| Diverged | The copy stopped matching the core's, so it stopped following it. | Core only | Resync on the mirror, or detach. | |
| Expired | The copy fell too far behind: the core no longer keeps the changes it missed. | Core only | Resync on the mirror, or detach. | |
| Stopped | The copy stopped following the core, with the reason. | Core only | Resync on the mirror, or detach. | |
| Switching | The core role is moving between the servers. | Neither, for a moment | Wait: it finishes or changes nothing. See Move the core. | |
| Replaced as the core | The other server took over while this one was cut off, and this one holds changes it never received. | Neither here | The old core comes back. | |
| Both took over | Both servers took over while cut off from each other. | Neither, on both | Both servers took over. | |
| Took over | This server took over as the core; the old core has not returned yet. | Yes, here | Nothing to do. When the old core returns, it stops taking changes and follows this server. |
Roles that are not a running mirror:
| Role | Console | What it means | Way out |
|---|---|---|---|
| Waiting for an answer · Waiting for you · Sending keys · Starting | An offer is out, its keys are being sent and checked, or the vault was just created on the mirror. Ended starts show Declined, Cancelled, Offer expired or Failed. | Accept or decline on the mirror (vh mirror pending); a failed or expired start: cancel it and offer again. | |
| Orphaned copy | The core ended the mirror (or the servers were unlinked) and this server kept its copy, read-only. | Orphaned copies. | |
| Detached | The copy was detached and is a vault of this server now. It still shares its id and keys with the original. | Re-key it (vh vault keys rotate); to mirror the two again, relink. |
A vault with held changes says so in vh mirror info and in the console's Held column. See
Held changes.
When The Link Drops
| On the | What happens | What to do |
|---|---|---|
| The vault keeps working. Changes are recorded and reach the mirror when the link returns. | Check the link: vh peer info <server> (Servers tab in the console). | |
The copy is read-only (the mount says "Read-only file system", vh and the console refuse with read_only). Files whose contents have not arrived cannot be opened. A file open for writing when the link dropped is kept and sent when it returns. | Wait: the link comes back by itself and the copy takes changes again. To use the files on their own now, detach. If the core is gone for good, take over. |
The link reconnects by itself after a restart or a network loss on either side. If it does not, see If Linking Fails.
Start A Stopped Copy Over (Resync)
A copy that is diverged, expired or stopped is brought back on the server that holds it, without making it again:
1vh mirror resync <vault>
Files whose bytes are already there are not downloaded again. Nothing a person wrote there is lost: changes that were
waiting, its own version of a file the core replaced, and anything the core does not have are kept as held changes
(vh mirror held). Resyncing needs the link to the core.
Both servers also check each mirrored vault once a day and stop it, with the reason, if its files no longer match what was recorded.
Move The Core (Switch)
While both servers are up and the vault is live, either server's super admin can swap the roles:
1vh mirror switch <vault>
For a few moments the vault is read-only on both servers (writes say why), the copy catches up with the last change, and then the other server is the core. The command prints which role the old core keeps on the vault.
- If anything gets in the way (changes made on the copy not confirmed yet, files whose contents have not arrived, the link dropping, either server stopping), the switch is abandoned, nothing changes, and the command says why.
- The server that hands over the role keeps the vault only through the role the new core gives it. With none, the
switch is refused, so its people do not lose the vault, unless you add
--accept-no-access. - Vaults with a cloud remote can't be switched.
- If the other server never comes back during a switch,
vh mirror infosays so: take over on the mirror, or detach.
The Core Is Gone (Take Over)
If a vault's core stops for good, make the mirror the core:
1vh mirror takeover <vault> --confirm <vault name>
A super admin may, or an account whose admin role has Take over as core (admin.mirror.takeover). The console's
Take over as core asks for the vault's name and confirms it's you.
- Changes made on the copy that were still waiting for the core become ordinary changes; changes the old core had refused stay listed as held changes. Files whose contents never arrived stay listed, marked missing.
- It warns that the old core may hold changes this server never received.
- It is refused while the old core still answers: use
vh mirror switchthen. - It is refused for a copy whose first copy has not finished, or that is
diverged. - It works while the old core was deleting the vault; the copy is then kept.
The Old Core Comes Back
A server that was taken over stops taking changes to the vault at once.
| What the old core did meanwhile | Result | What to do |
|---|---|---|
| It becomes the new core's mirror by itself. | Nothing. | |
It keeps them and stays read-only (rejoining, Replaced as the core). vh mirror info on both servers says how many changes. | On the old core: vh mirror resync <vault> to follow the new core (its changes are kept as held changes), vh mirror detach <vault> to keep it as its own vault, or relink to go through the differences. |
Both Servers Took Over
If both servers took over while cut off from each other, the vault is forked and read-only on both. Pick the server
whose files stay. On the other one, run vh mirror resync <vault> (what only it has is kept as held changes) or
vh mirror detach <vault>. To choose entry by entry instead, relink. Detaching either server's
copy ends a take over cleanly on both.
The Core Is Deleting The Vault
When the core deletes a mirrored vault, the copy is read-only on the mirror until the purge, which vh mirror info
shows with its date. Then the copy is removed or kept as an orphaned copy, as the core chose with --mirror-copy.
- To keep the vault and its mirror: restore it on the core (
vh vault restore, or Vaults › Deleted vaults) before the purge. - To keep the files on the mirror whatever the core does: detach the copy before the purge.
Orphaned Copies
An orphaned copy is read-only and follows nothing. Three things can be done with it:
1vh mirror detach <vault> # keep it as this server's own vault2vh mirror cancel <vault> # remove it and its keys from this server3vh mirror relink <vault> --with <server> # mirror it again with the server that holds it too
Leave With The Files (Detach)
The server holding a copy can always walk away with it as an ordinary vault of its own, whatever state the copy is in (live, stopped, diverged, expired or orphaned) and whether the core is reachable or not. Nothing is asked of the core, which is told when it is next reachable and ends the mirror on its side.
See what you would get
1vh mirror detach <vault> --dry-run # add --json to export the listIt shows where the copy left the core's history, whether it was confirmed identical there, the changes made here not yet confirmed (they become ordinary changes), and every file whose contents never arrived.
Detach
1vh mirror detach <vault> --owner <user> # default owner: youRe-key it
The detached vault keeps the original's id and keys, so the two servers won't mirror it with each other again (except through a relink), and
vh mirror listlists it as detached with a re-key recommended:1vh vault keys rotate <vault>
Files whose contents never arrived stay listed, marked missing: opening one says so and never shows empty or wrong
contents. Nothing is deleted on either server and no bucket is touched. A super admin may detach, or an account whose
admin role has Detach mirrored vaults (admin.mirror.detach).
Detach a copy instead
To keep the mirror running and also get a separate vault, write a new vault from the copy:
1vh mirror detach <vault> --copy [--name <name>] [--owner <user>]2vh mirror detach <vault> --copy --status # how far it is3vh mirror detach <vault> --copy --cancel # stop it and remove the partial vault
The copy stays as it is (it keeps following its core, or stays read-only). The new vault has its own id and its own
key, every folder, file and symlink with their modes and modification times, and none of the trash, versions, shares
or access rules. It runs in the background, needs room for a second copy (refused up front otherwise), lists exactly
the files whose contents never arrived (they are left out), and ends with a complete vault or none. Its default name
is "<name> copy".
Related: Reconnecting A Mirror, vh mirror.
