vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Rewrite documentation around reader tasks
d1f44d838966c0a4762073f12375ec7562582fdf · Keenan Nemetz · 21h ago · parent 9103f6a8
docs/backup-and-restore.md +201
| @@ -0,0 +1,201 @@ | |||
| 1 | # Backup and restore | ||
| 2 | |||
| 3 | Back up every part of an instance that Git cannot rebuild, and test recovery | ||
| 4 | before you need it. A backup that has never been restored is an assumption, not | ||
| 5 | a recovery plan. | ||
| 6 | |||
| 7 | The procedures below run from the instance directory containing `vole.toml` and | ||
| 8 | `data/`. Start Vole at least once before backing it up so it creates its SSH host | ||
| 9 | key. Use an account that can read all instance files. Commands for a packaged | ||
| 10 | Linux service use `sudo`; for a local instance, stop `vole serve` with `Ctrl+C` | ||
| 11 | and run the Vole commands as the instance owner. | ||
| 12 | |||
| 13 | ## What to back up | ||
| 14 | |||
| 15 | | Back up | Rebuild instead | | ||
| 16 | |---|---| | ||
| 17 | | `data/instance.db` — accounts, access rules, CI history, release channels, and sealed secrets | `data/index.db` — rebuild with `vole admin index rebuild` | | ||
| 18 | | `data/repos/` — source and collaboration history | | | ||
| 19 | | `data/lfs/` — large files and build artifacts | | | ||
| 20 | | `data/logs/` — CI attempt logs | | | ||
| 21 | | `data/ssh_host_ed25519_key` — Vole's SSH host key | | | ||
| 22 | | `data/audit.log` — privileged-action history | | | ||
| 23 | | `data/acme/` — automatic HTTPS account and certificates | Vole can request new certificates, but backing them up avoids that work | | ||
| 24 | | `data/secrets.key` — store separately from the rest of the backup | | | ||
| 25 | |||
| 26 | [Instance data](configuration.md#instance-data) explains the storage model. | ||
| 27 | |||
| 28 | ## Back up an instance | ||
| 29 | |||
| 30 | The procedure creates an application backup in `backup/` and stores the | ||
| 31 | secrets-encryption key separately in `key-backup/`. | ||
| 32 | |||
| 33 | ### 1. Stop writes | ||
| 34 | |||
| 35 | For a point-in-time copy of every file, stop the packaged service: | ||
| 36 | |||
| 37 | ```sh | ||
| 38 | sudo systemctl stop vole | ||
| 39 | ``` | ||
| 40 | |||
| 41 | Stopping the service interrupts web and Git access. If you cannot stop it, the | ||
| 42 | database command below is safe while Vole runs, but clone every repository | ||
| 43 | instead of copying live repository directories and expect the other files to be | ||
| 44 | only an approximate point in time. | ||
| 45 | |||
| 46 | ### 2. Create private backup directories | ||
| 47 | |||
| 48 | ```sh | ||
| 49 | install -d -m 0700 backup key-backup | ||
| 50 | ``` | ||
| 51 | |||
| 52 | ### 3. Copy the authoritative database | ||
| 53 | |||
| 54 | ```sh | ||
| 55 | vole admin db backup backup | ||
| 56 | ``` | ||
| 57 | |||
| 58 | This writes `backup/instance.db` with SQLite `VACUUM INTO`, preserving recent | ||
| 59 | transactions in the write-ahead log. A plain copy of a live database can miss | ||
| 60 | those transactions. The command skips the derived `index.db` and does not copy | ||
| 61 | `secrets.key`. | ||
| 62 | |||
| 63 | Use `vole admin db list` to see the databases and their backup classification. | ||
| 64 | |||
| 65 | ### 4. Copy repositories and stored files | ||
| 66 | |||
| 67 | ```sh | ||
| 68 | cp -a data/repos backup/ | ||
| 69 | cp -a data/lfs backup/ | ||
| 70 | cp -a data/logs backup/ | ||
| 71 | cp -a data/acme backup/ 2>/dev/null || true | ||
| 72 | cp data/ssh_host_ed25519_key backup/ | ||
| 73 | cp data/audit.log backup/ | ||
| 74 | ``` | ||
| 75 | |||
| 76 | An instance using the [sshd front door](deploy/linux.md#put-sshd-in-front-of-vole) | ||
| 77 | presents the system SSH host key instead. Copy that private key too: | ||
| 78 | |||
| 79 | ```sh | ||
| 80 | sudo install -m 0600 /etc/ssh/ssh_host_ed25519_key backup/ssh_host_ed25519_key.sshd | ||
| 81 | ``` | ||
| 82 | |||
| 83 | A restore that omits the active host key changes the identity that Git clients | ||
| 84 | and CI runners verify. | ||
| 85 | |||
| 86 | ### 5. Store the secrets key separately | ||
| 87 | |||
| 88 | ```sh | ||
| 89 | install -m 0600 data/secrets.key key-backup/secrets.key | ||
| 90 | ``` | ||
| 91 | |||
| 92 | If `secrets_key` names another path, copy that file instead. | ||
| 93 | |||
| 94 | !!! danger "Keep the key out of the database backup" | ||
| 95 | A copy containing both `instance.db` and `secrets.key` is effectively a copy | ||
| 96 | of the repository secrets in plaintext. Store the key separately. Losing it | ||
| 97 | makes the sealed secret rows unreadable. | ||
| 98 | |||
| 99 | ### 6. Restart and move the backups off the machine | ||
| 100 | |||
| 101 | ```sh | ||
| 102 | sudo systemctl start vole | ||
| 103 | ``` | ||
| 104 | |||
| 105 | Move both backup sets to protected off-machine storage and record which one | ||
| 106 | holds the encryption key. The database contains account metadata, access rules, | ||
| 107 | CI history, and sealed secret ciphertext, so treat it as private even without | ||
| 108 | the key. | ||
| 109 | |||
| 110 | ## Restore an instance | ||
| 111 | |||
| 112 | Restore a complete backup set into an empty data directory. Do not merge it with | ||
| 113 | files from a different point in time or leave a running server writing to it. | ||
| 114 | |||
| 115 | ### 1. Stop Vole and preserve the current directory | ||
| 116 | |||
| 117 | On a packaged installation: | ||
| 118 | |||
| 119 | ```sh | ||
| 120 | sudo systemctl stop vole | ||
| 121 | mv data data.before-restore | ||
| 122 | install -d -m 0750 data | ||
| 123 | ``` | ||
| 124 | |||
| 125 | Keep `data.before-restore` until the restored instance passes verification. For | ||
| 126 | a local instance, stop `vole serve` first and run the same commands as its owner. | ||
| 127 | |||
| 128 | ### 2. Restore one backup set | ||
| 129 | |||
| 130 | From the instance directory, copy the files back: | ||
| 131 | |||
| 132 | ```sh | ||
| 133 | cp backup/instance.db data/ | ||
| 134 | cp -a backup/repos data/ | ||
| 135 | cp -a backup/lfs data/ | ||
| 136 | cp -a backup/logs data/ | ||
| 137 | cp -a backup/acme data/ 2>/dev/null || true | ||
| 138 | cp backup/ssh_host_ed25519_key data/ | ||
| 139 | cp backup/audit.log data/ | ||
| 140 | install -m 0600 key-backup/secrets.key data/secrets.key | ||
| 141 | ``` | ||
| 142 | |||
| 143 | If `secrets_key` names another path, restore the key there instead. For an sshd | ||
| 144 | front-door instance, also restore | ||
| 145 | `backup/ssh_host_ed25519_key.sshd` to `/etc/ssh/ssh_host_ed25519_key` with mode | ||
| 146 | `0600`, then restart or reload sshd according to your distribution. | ||
| 147 | |||
| 148 | On a packaged installation, return ownership to the service account: | ||
| 149 | |||
| 150 | ```sh | ||
| 151 | chown -R vole:vole data | ||
| 152 | chmod 0600 data/secrets.key data/ssh_host_ed25519_key | ||
| 153 | ``` | ||
| 154 | |||
| 155 | ### 3. Rebuild derived indexes and revoke restored sessions | ||
| 156 | |||
| 157 | From a local instance directory, run: | ||
| 158 | |||
| 159 | ```sh | ||
| 160 | vole admin index rebuild | ||
| 161 | vole admin account revoke-sessions --all | ||
| 162 | ``` | ||
| 163 | |||
| 164 | For the packaged installation, run them as the service account: | ||
| 165 | |||
| 166 | ```sh | ||
| 167 | sudo -u vole vole admin --config /etc/vole/vole.toml index rebuild | ||
| 168 | sudo -u vole vole admin --config /etc/vole/vole.toml account revoke-sessions --all | ||
| 169 | ``` | ||
| 170 | |||
| 171 | Revoking sessions prevents browser cookies from the old system from outliving | ||
| 172 | the restored revocation state. Rebuilding the index does not restore any unique | ||
| 173 | data; it reconstructs derived repository, activity, and search records from Git. | ||
| 174 | |||
| 175 | ### 4. Start Vole and verify recovery | ||
| 176 | |||
| 177 | ```sh | ||
| 178 | sudo systemctl start vole | ||
| 179 | ``` | ||
| 180 | |||
| 181 | Check all of the following before returning the instance to service: | ||
| 182 | |||
| 183 | - account sign-in and an SSH clone; | ||
| 184 | - source, issue, and change-request pages; | ||
| 185 | - CI history and a stored artifact; | ||
| 186 | - a release download and any hosted sites; | ||
| 187 | - runner connectivity and the expected SSH host key. | ||
| 188 | |||
| 189 | Once those checks pass, remove `data.before-restore` according to your retention | ||
| 190 | policy. If `instance.db` is unrecoverable, repositories remain usable, but you | ||
| 191 | must recreate accounts, credentials, access rules, release channels, and CI | ||
| 192 | history. Finished runs and in-flight queue state cannot be reconstructed from | ||
| 193 | Git. | ||
| 194 | |||
| 195 | ## Next | ||
| 196 | |||
| 197 | - [Upgrade an installed server](install.md#upgrade-an-installed-server) — install | ||
| 198 | a release after a tested backup. | ||
| 199 | - [Instance data](configuration.md#instance-data) — authoritative and derived | ||
| 200 | storage. | ||
| 201 | - [LFS and file locking](lfs.md#clean-up-unused-objects) — reclaim stored objects. | ||