VergVault
How VergVault keeps your source code
VergVault keeps your git repositories in more than one place, on machines you already own. One machine of your network, the primary, holds them. Other machines of the same network keep copies, fetched over the private network of VergMesh. Nothing leaves your machines unless you add a mirror, and the console never holds your code: it holds names, addresses and what each machine reports about its copy.
It runs on Linux nodes. A Mac, a phone or a node set up by hand cannot hold a vault in this version; the console says so when you try.
Set one up
- Join the machines to a VergMesh network.
- Under VergVault, make a vault: pick the primary, the machines that keep copies, how often to copy, and the repositories.
- Each machine makes its folder at its next report, within a minute. By default that is
/srv/verg-vault/<name>, owned by a user calledverg-vaultthat the agent makes. It has no login shell except git's own, so it can run git and nothing else. - Push your repositories to the primary, or let the vault pick up bare repositories that are already in its folder: the page lists the ones it finds and you adopt them.
How copies are made
Every machine runs a read-only git service on its private address, on a port of the vault (9418 to 9517, one for each vault of a network). Machines never push to each other. Each one fetches from its sources and moves its own branches forward.
| Mode | Who fetches from whom |
|---|---|
| Copies follow the primary (the default) | Copies fetch from the primary. The primary fetches from nobody. Safe: a copy only receives. |
| Two way | Every machine fetches from every other, so a push to any of them reaches all. A branch that two machines changed differently is reported, never merged for you. |
What it never does
- It never forces. A branch only moves forward to a commit that contains the old one.
- It never deletes your data. Removing a repository, a machine or the whole vault from the console stops copying. The folders stay.
- A diverged branch is left alone on both sides and reported. You decide which history to keep.
- A tag is never moved. A missing tag is copied. A tag that points somewhere else on another machine is listed on the vault page, as a difference, and not changed.
- A branch deleted on the source is deleted on a copy only when the copy still holds exactly the commit it last agreed on. A copy that moved on is kept. Even then the commit is saved under a hidden name so you can get it back. In detail, it is first written to a hidden reference (
refs/verg/kept/<time>/heads/<branch>) in the same step, nothing is ever pruned from a vault repository (gc.pruneExpire=never, reflogs kept), and a source that suddenly lacks more than 3 of the branches it had, or all of them, deletes nothing: the machine reports a source lost many branches at once (mass_delete) until the source has them again. A mirror only has a branch deleted that was kept this way. - Every git command in a vault folder runs as the owner of that folder, never as root, so a repository's own settings can never run code as root.
Folders and users other than the default
The default is a folder under /srv/verg-vault/ owned by the user verg-vault. Anything else (another user, another folder, for instance the repositories of a Git server you already run) is only served when a person on that machine allows it, because the console must never be able to point a vault at someone else's files. Put one line for each user and folder in /etc/verg/vault-paths, a file that belongs to root and that nobody else can write:
echo 'git /var/lib/git/repositories' | sudo tee -a /etc/verg/vault-paths
sudo chown root:root /etc/verg/vault-paths && sudo chmod 644 /etc/verg/vault-paths
sudo verg-agent sync
Each line is the user, a space and the beginning of the folder (git /var/lib/git/repositories allows that folder and everything under it, for that user only). Until then the machine reports path_local for the vault and makes, serves and pushes nothing for it. A folder under /home is never allowed. sudo verg-agent doctor prints the exact line to add.
The firewall
For each machine of a vault the console adds one rule to the firewall of VergShield: the other machines of that vault may connect to the vault port, and nobody else. It is added for you and shows nowhere else; a machine in no vault gets nothing new. If the machine has another firewall of its own, such as ufw, let the private network through it (ufw allow in on verg0).
Push keys
To push over ssh, add a public key under Settings, Push keys. Paste the .pub file, never a private key. Only ed25519 and ecdsa keys work (make one with ssh-keygen -t ed25519); RSA keys are not accepted. The key is written to the verg-vault user of each machine, restricted so it can only run git-receive-pack, git-upload-pack and git-upload-archive on the folders of that vault. At most 20 keys for a vault.
Mirrors to GitHub or GitLab
A mirror copies every repository to an account you own on a git host, pushing only. It is on the Starter, Team and Business plans. Give the address of one repository over ssh with {repo} where its name goes, for example [email protected]:your-company/{repo}.git. The primary makes an ssh key for the mirror (the private half never leaves that machine, and the console never asks for a password or a key) and shows you the public key. On that machine the private half is a file that only the vault's user can read, in /var/lib/verg-vault-keys, a folder only root can list. If a mirror reports key_unreadable, that file does not belong to the vault's user (for example after the user was changed); remove the folder of that mirror under /var/lib/verg-vault-keys on the primary and a new key is made, which you then add on the host again. Add it on the host, create an empty private repository for each name, and the repositories are pushed.
A machine pushes mirrors to github.com and gitlab.com only. For any other host, the administrator of the primary machine adds a line mirror git.example.com to /etc/verg/vault-paths (the same file, with the same rules: owned by root, writable by nobody else). Until then the mirror reports mirror_host and nothing is sent. The key of such a host is trusted the first time the machine connects to it.
New repositories are pushed one at a time, at least 90 seconds apart, and at most 3 a day in the first week of a mirror, 5 a day in the second week and 8 a day after that (UTC days). Every try counts in that number, including a repository that was held for you (the key or the empty repository was missing) and is tried again. A held repository is tried again at most once a day, when no new repository can go (none is waiting, or each one is still inside the hour it waits after a failed push). A first push that keeps failing for more than a day is put on hold and tried again the same way. We do this because a new account that suddenly pushes many repositories can be flagged by the host. When the host says to slow down, nothing is pushed to it for the rest of that UTC day. After the first push, a repository is pushed again when its branches or tags changed and the mirror's interval (240 minutes unless you choose another) has passed.
A branch deleted in the vault is deleted on the mirror only when the mirror still holds the commit we pushed last. A history the mirror has and the vault does not is never overwritten: it is shown as diverged.
GitHub Actions: switch them off on a new private repository that does not use them (Settings, Actions, General). The console cannot do this over ssh, so it is yours to do on the host.
Restore, and prove it works
The Restore page shows, for each repository and each machine, the exact commands: clone over ssh as verg-vault@<address>:<folder>/<repository>.git, clone from another machine of the vault over the private network with git://, and git remote set-url origin ... to point a clone you already have at a copy. After losing the primary, promote a copy under Settings: it becomes the primary, and the old primary becomes a copy. Mirrors then push from the new primary with a key of its own, which you add on the host.
Verify a restore asks a machine to clone each repository from its own copy into a temporary folder, run git fsck on the clone, compare its branches with the copy and delete the clone. It changes nothing in your repositories, takes one check at a time on a machine and gives up after 30 minutes. The results are listed with the date, so you can show when a restore last worked.
Restore checks on a schedule
A restore check is run for you. Every 30 days by default, or every 7 or 90 days, or never (Settings, Check a restore), the console asks one machine of the vault to clone every repository from its own copy into a temporary folder, run git fsck on the clone, compare its branches with the copy and delete the clone. It never touches the repositories themselves: it only reads them. Each time it is a different machine of the vault, the primary included, taking the one that was checked longest ago, so every copy is proved over time. A machine runs one check at a time, and a scheduled check starts on a given machine at most once an hour, so checks never pile up on one machine.
When a scheduled check fails, or the machine does not answer, a VergMind incident opens for the vault, with the machine and what went wrong. A failed check is tried again within a day, and the incident closes by itself when a check passes. The Restore page lists every check, the ones you started and the ones on schedule, with the date, the machine, the result and how many repositories and branches it covered. Download the record there gives the last 400 days as a CSV file to keep, or read it from GET /v1/vault/vaults/{vault}/restore-record as JSON, or add ?format=csv.
Alerts
Problems are VergMind incidents, one for each vault and check, and they close by themselves when the problem is gone. The alert kind is A copy of your source code is stale, behind or damaged. An all-monitors maintenance window holds them.
| Check | Opens when | Level |
|---|---|---|
| A machine has not copied | It did not complete a run that reached its sources for three times the schedule, and never less than an hour | Warning |
| A copy is behind | A copy still differs from its source after that time | Warning |
| A branch diverged | Two machines have different history for a branch. Lists up to 10 as repository:branch | Warning |
| Damage found in a copy | Weekly check found damage in a repository on a machine | Problem (pages) |
| A scheduled restore check failed | The check on a machine failed or got no answer, and no check has passed since | Warning |
| A mirror is failing | A push has failed for 24 hours, or the host asked us to slow down | Warning |
VergProof
The control Source code is kept in two or more places and checked weekly is met when every repository has a copy on at least two different machines, each copied within the last 24 hours, and each copy passed git fsck within the last 8 days. It is partly met when every repository has two copies but one is stale or not checked, and not met when a repository has one copy or its copies never synced. With no vault it does not apply. It gives evidence for ISO/IEC 27001:2022 A.8.13, NIST CSF 2.0 PR.DS-11, CIS Controls 11.2 and 11.3, HIPAA 164.308(a)(7)(ii)(A) and SOC 2 A1.2, and shows when a restore was last verified. Copy at least every 12 hours for it to hold. Scheduled restore checks keep that date fresh by themselves: a passing check in the last 90 days is what the control counts.
Plans
Free: 1 vault, 5 repositories. Starter: 2 vaults, 25 repositories. Team: 5 vaults, 200 repositories. Business: 25 vaults, 1000 repositories. Repositories are counted across the workspace. A plan that ends never stops copying or pushing what exists: it only refuses a new vault, repository or mirror over the limit.
API
All calls need a workspace key. Reads need a read key; changes need a read and write key and accept an Idempotency-Key header, so a retry never makes a second vault. A vault is addressed by its id or its name.
curl -s -X POST https://api.cloudverg.com/v1/vault/vaults \
-H "Authorization: Bearer $VERG_API_KEY" -H "Idempotency-Key: $(uuidgen)" -H "Content-Type: application/json" \
-d '{"name":"Company code","network":"prod","primary":"git-1","replicas":["git-2","office-nas"],"mode":"follow","every_min":15,"repositories":["website","backend"]}'curl -s https://api.cloudverg.com/v1/vault/vaults/company-code -H "Authorization: Bearer $VERG_API_KEY"curl -s -X POST https://api.cloudverg.com/v1/vault/vaults/company-code/verify \
-H "Authorization: Bearer $VERG_API_KEY" -H "Content-Type: application/json" -d '{"node":"office-nas"}'GET /v1/vault/vaults list
POST /v1/vault/vaults make one
GET /v1/vault/vaults/{vault} machines, every repository on every machine, keys, mirrors, health
PATCH /v1/vault/vaults/{vault} name, mode, every_min, restore_check_every_days (0, 7, 30 or 90), primary (promote a copy)
DELETE /v1/vault/vaults/{vault} stop managing it; the repositories stay on the machines
POST /v1/vault/vaults/{vault}/members {node, path?, owner?}
PATCH /v1/vault/vaults/{vault}/members/{node} {path?, owner?}
DELETE /v1/vault/vaults/{vault}/members/{node}
POST /v1/vault/vaults/{vault}/repos {names: [...]} add or adopt
DELETE /v1/vault/vaults/{vault}/repos/{repo} stop copying it; the folders stay
GET /v1/vault/vaults/{vault}/keys
POST /v1/vault/vaults/{vault}/keys {public_key, label?}
DELETE /v1/vault/vaults/{vault}/keys/{key}
GET /v1/vault/vaults/{vault}/mirrors
POST /v1/vault/vaults/{vault}/mirrors {url_template, key_mode?, every_min?}
PATCH /v1/vault/vaults/{vault}/mirrors/{mirror} {enabled?, every_min?}
DELETE /v1/vault/vaults/{vault}/mirrors/{mirror}
POST /v1/vault/vaults/{vault}/mirrors/{mirror}/resume
POST /v1/vault/vaults/{vault}/mirrors/{mirror}/repos/{repo}/retry
POST /v1/vault/vaults/{vault}/sync copy now
POST /v1/vault/vaults/{vault}/verify {node, repo?}
GET /v1/vault/vaults/{vault}/verifies
GET /v1/vault/vaults/{vault}/restore-record the last 400 days; add ?format=csv for a file
GET /v1/vault/healthAt most 300 repositories, 10 machines and 5 mirrors in a vault, and 8 vaults on a machine. A change that would give a machine more than one reply or one report can carry is refused, and says which machine. A vault is copied every 5, 15, 30, 60, 360, 1440 minutes, or any number from 5 to 1440 through the API.