Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

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.

Merge release channels into the account database and rename it instance.db

3047be84e9bce79372051c09854ce9b05f12a9bf · Keenan Nemetz · 17d ago · parent 262e516e

Merge release channels into the account database and rename it instance.db

The instance keeps four SQLite files instead of five. Release channels were in a
file of their own only because they were added beside the derived index; they are
authoritative source state, like the roster, so they belong in the file an
operator restores. Nothing has to be migrated: channels.db never shipped in a
release, so only an instance tracking main can have one.

The account database is now data/instance.db. The package comments already called
it that; only the filename disagreed.

Moving an existing instance is an operator step, by decision: a rename under a
live server can lose the -wal file a hook subprocess still has open. Vole refuses
to start while data/users.db is still in place, and says what to move, rather
than creating an empty database beside it that would look like a successful
upgrade.

The list of databases now lives in Config.Databases, which TightenSecrets, the
hook plumbing, and the admin commands read, so a missed -wal file is no longer a
nine-file change. `vole admin account backup <path>` becomes `vole admin db
backup <dir>` and covers every authoritative database; `db list` and `db check`
answer what to back up and whether it is intact.

docs/operations.md +75−23

@@ -36,12 +36,11 @@ Before exposing an instance, verify these controls:
36 36
37 37 ## Back up an instance
38 38
39 Back up all authoritative state, not only `users.db`. The procedure below creates
40 an application copy in `backup/` and stores the secrets-encryption key separately
41 in `key-backup/`. Run it from the instance directory containing `vole.toml` and
42 `data/`, as an account that can read all instance files and write the backups.
43 Install SQLite's `sqlite3` command-line tool before using this procedure; the
44 Vole package's SQLite library dependency does not provide that tool.
39 Back up all authoritative state, not only the instance database. The procedure
40 below creates an application copy in `backup/` and stores the secrets-encryption
41 key separately in `key-backup/`. Run it from the instance directory containing
42 `vole.toml` and `data/`, as an account that can read all instance files and write
43 the backups.
45 44
46 45 For a point-in-time copy, stop writes first. On a packaged installation:
47 46
@@ -50,7 +49,7 @@ sudo systemctl stop vole
50 49 ```
51 50
52 51 Stopping the service interrupts web and Git access. If you cannot stop it, use
53 the online-safe database backup commands below and clone each repository instead
52 the online-safe database backup command below and clone each repository instead
54 53 of copying a live repository directory.
55 54
56 55 ### 1. Create private backup directories
@@ -59,17 +58,18 @@ of copying a live repository directory.
59 58 install -d -m 0700 backup key-backup
60 59 ```
61 60
62 ### 2. Copy the account and CI databases consistently
61 ### 2. Copy the databases consistently
63 62
64 63 ```sh
65 vole admin account backup backup/users.db
66 sqlite3 data/runs.db ".backup 'backup/runs.db'"
67 sqlite3 data/secrets.db ".backup 'backup/secrets.db'"
68 sqlite3 data/channels.db ".backup 'backup/channels.db'"
64 vole admin db backup backup
69 65 ```
70 66
71 These commands preserve SQLite WAL contents. A plain file copy of a live database
72 can miss recent transactions.
67 This writes a copy of every authoritative database — `instance.db`, `runs.db`,
68 and `secrets.db` — with `VACUUM INTO`, which preserves SQLite WAL contents while
69 the instance runs. A plain file copy of a live database can miss recent
70 transactions, and copying a database without its `-wal` file can roll it back.
71 `data/index.db` is skipped because it is derived. `vole admin db list` shows the
72 files and which ones a backup needs.
73 73
74 74 ### 3. Copy repositories and stored files
75 75
@@ -82,9 +82,9 @@ cp data/ssh_host_ed25519_key backup/
82 82 cp data/audit.log backup/
83 83 ```
84 84
85 `data/index.db` is derived and does not need a backup. `data/runs.db` is
86 authoritative CI history and queue state; `data/channels.db` is authoritative
87 release-channel state. Do not omit either.
85 `data/index.db` is derived and does not need a backup: `vole admin index rebuild`
86 recreates it from the repositories. Every other database was copied by
87 `vole admin db backup`.
88 88
89 89 ### 4. Copy the secrets key to separate protected storage
90 90
@@ -108,7 +108,7 @@ sudo systemctl start vole
108 108 Record which backup holds the encryption key and test the restore procedure
109 109 below.
110 110
111 The account backup contains public keys and hashes of session and enrollment
111 The database backup contains public keys and hashes of session and enrollment
112 112 tokens, not plaintext sessions or passwords. Treat it as private because it also
113 113 contains account metadata and access rules.
114 114
@@ -126,9 +126,8 @@ sudo systemctl stop vole
126 126 ### 2. Restore these paths from the same backup
127 127
128 128 ```text
129 data/users.db
129 data/instance.db
130 130 data/runs.db
131 data/channels.db
132 131 data/secrets.db
133 132 data/secrets.key
134 133 data/repos/
@@ -148,7 +147,7 @@ belong to the service account and private keys have mode `0600`.
148 147 vole admin index rebuild
149 148 ```
150 149
151 ### 4. Revoke browser sessions from the restored account database
150 ### 4. Revoke browser sessions from the restored database
152 151
153 152 ```sh
154 153 vole admin account revoke-sessions --all
@@ -166,11 +165,64 @@ sudo systemctl start vole
166 165 Then check account sign-in, an SSH clone, a repository page, CI history, a stored
167 166 artifact, and any hosted sites.
168 167
169 If the account database is unrecoverable, repositories remain usable, but you
168 If the instance database is unrecoverable, repositories remain usable, but you
170 169 must recreate accounts, keys, passkeys, and access rules. If `runs.db` is lost,
171 170 current refs can be queued again, but finished CI history and in-flight work are
172 171 lost.
173 172
173 ## Upgrade to the instance database
174
175 Before this version, the account database was `data/users.db` and release
176 channels were `data/channels.db`. Both now live in `data/instance.db`. Vole does
177 not move the file itself: a rename under a running server can lose the `-wal`
178 file that a hook subprocess still has open, and creating a fresh empty database
179 beside the old one would look like a successful upgrade.
180
181 An instance installed from a release has no `channels.db`; the channel feature
182 never shipped. Only an instance tracking `main` in that window can have one.
183
184 ### 1. Stop Vole
185
186 ```sh
187 sudo systemctl stop vole
188 ```
189
190 ### 2. Move the account database
191
192 Take the write-ahead file with it. A plain `mv` of the database alone silently
193 rolls back the transactions still in `users.db-wal`.
194
195 ```sh
196 mv data/users.db data/instance.db
197 mv data/users.db-wal data/instance.db-wal 2>/dev/null || true
198 rm -f data/users.db-shm
199 ```
200
201 ### 3. Move any release channels
202
203 If `data/channels.db` exists, copy its rows into the new `data/instance.db`, then
204 delete it with its siblings. The channel table has no foreign keys, so the rows
205 transfer as they are. This is the one step that needs SQLite's `sqlite3` command
206 line tool; the Vole package does not install it, and a package-installed instance
207 never took this branch.
208
209 ```sh
210 sqlite3 data/instance.db "ATTACH 'data/channels.db' AS old;
211 INSERT OR IGNORE INTO release_channels SELECT * FROM old.release_channels;"
212 rm -f data/channels.db data/channels.db-wal data/channels.db-shm
213 ```
214
215 ### 4. Start Vole and verify
216
217 ```sh
218 sudo systemctl start vole
219 ```
220
221 `vole admin db list` should show `instance.db` as present and authoritative.
222 Confirm that accounts sign in, a repository page renders, and any channel URL
223 still resolves. Vole refuses to start while `data/users.db` or
224 `data/channels.db` is left beside the new file, and says which one to move.
225
174 226 ## Audit log
175 227
176 228 `data/audit.log` records roster and key changes, access rules, forced overrides,
@@ -232,7 +284,7 @@ vole admin index rebuild
232 284 ```
233 285
234 286 This restores repository, issue, change, activity, and search indexes from Git
235 and stored records. It does not restore `data/runs.db`, `data/channels.db`,
287 and stored records. It does not restore `data/runs.db`, `data/instance.db`,
236 288 accounts, secrets, logs, or artifacts.
237 289
238 290 ## Security notes