A backup of a :pg-snapshot store, taken from the browser before a large edit.
Such a store is in two places: its directory holds the index and reasoning images and
the operation log, and a Postgres schema holds the records (index/records.edn names
the schema). A backup is both, as of one state, in a new directory beside the store:
| file | |
|---|---|
store/ | an APFS clone (cp -c) of the store directory, its lock file left out |
records.dump | pg_dump --format=custom of the schema |
backup.edn | where it came from, the seal, the time, and how to restore it |
One state. The job seals the KB first, so the images name the records as they
stand (v/seal), and holds the process's writer claim and the browser's write monitor
(:run-in) from before the seal to after the dump, so nothing writes between the
three. pg_dump reads its schema in one snapshot transaction.
Restore is by hand and takes the KB offline: unload it, rename the schema out of
the way, pg_restore the dump (which recreates the schema under its own name), put
store/ back in the store directory's place, and load the store. backup.edn
carries the commands. The images then open against the restored records, since
pg_dump keeps the fingerprint row they were sealed against.
A backup of a `:pg-snapshot` store, taken from the browser before a large edit. Such a store is in two places: its directory holds the index and reasoning images and the operation log, and a Postgres schema holds the records (`index/records.edn` names the schema). A backup is both, as of one state, in a new directory beside the store: | file | | |---|---| | `store/` | an APFS clone (`cp -c`) of the store directory, its lock file left out | | `records.dump` | `pg_dump --format=custom` of the schema | | `backup.edn` | where it came from, the seal, the time, and how to restore it | **One state.** The job seals the KB first, so the images name the records as they stand (`v/seal`), and holds the process's writer claim and the browser's write monitor (`:run-in`) from before the seal to after the dump, so nothing writes between the three. `pg_dump` reads its schema in one snapshot transaction. **Restore** is by hand and takes the KB offline: unload it, rename the schema out of the way, `pg_restore` the dump (which recreates the schema under its own name), put `store/` back in the store directory's place, and load the store. `backup.edn` carries the commands. The images then open against the restored records, since `pg_dump` keeps the fingerprint row they were sealed against.
(backup! kb dir out progress!)Back up the :pg-snapshot KB kb, whose store directory is dir, into the new
directory out (see the namespace doc), reporting to progress!, and return what
backup.edn says. The caller holds off writes for the whole call. A backup that
fails or is cancelled deletes out, and touches nothing else.
Back up the `:pg-snapshot` KB `kb`, whose store directory is `dir`, into the new directory `out` (see the namespace doc), reporting to `progress!`, and return what `backup.edn` says. The caller holds off writes for the whole call. A backup that fails or is cancelled deletes `out`, and touches nothing else.
(backup-dir dir at)Where a backup of store directory dir taken at at goes: beside it, named after it
and the time.
Where a backup of store directory `dir` taken at `at` goes: beside it, named after it and the time.
(backup-entry! key {:keys [run-in] :or {run-in (fn [work] (work))}})Back up the :pg-snapshot store in entry key as a :backup job (backup!) and
return the job id. :run-in wraps the work, which is how the browser hands its write
monitor. Refuses what refusal names, and {:type :job-busy} while another job holds
the writer.
Back up the `:pg-snapshot` store in entry `key` as a `:backup` job (`backup!`) and
return the job id. `:run-in` wraps the work, which is how the browser hands its write
monitor. Refuses what `refusal` names, and `{:type :job-busy}` while another job holds
the writer.(pg-dump-command {:keys [host port db schema]} file)The pg_dump argv writing schema schema of {:host :port :db} to file. It is
the pg_dump on the PATH, which must be at least the server's version, connecting as
pg_dump itself decides (PGUSER, else the OS user), as the store's own connection
does.
The `pg_dump` argv writing schema `schema` of `{:host :port :db}` to `file`. It is
the `pg_dump` on the PATH, which must be at least the server's version, connecting as
`pg_dump` itself decides (`PGUSER`, else the OS user), as the store's own connection
does.(refusal key)Why entry key cannot be backed up, as an ex-info, or nil.
Why entry `key` cannot be backed up, as an ex-info, or nil.
(store-records dir)The Postgres location a :pg-snapshot store directory names, as {:host :port :db :schema}, read off its index/records.edn; nil when it names none.
The Postgres location a `:pg-snapshot` store directory names, as `{:host :port :db
:schema}`, read off its `index/records.edn`; nil when it names none.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |