Skip to main content

Module backup

Module backup 

Source
Expand description

The workspace backup: frequent snapshots of Work/ in a git folder of its own under Backup/, and bringing the workspace or one file back from any of them.

Workspaces/<workspace>/
  Backup/
    Code.git/     the snapshots, git's own folder with no working tree
    Assets.git/      the snapshots of `Assets/`, when the workspace asks for them
    backup.lock      held while a snapshot or a restore of the workspace runs
    assets.lock      held while one of `Assets/` runs

The backup sits beside the workspace, so it moves and is copied with it. It guards against a wrong delete, a change that breaks things and a harness scattering files, not against a failing disk.

git does not run on the machine: QCode promises to run no program there, and the machine may have no git. Every job runs in a one-off container of the base image that sees the workspace and Backup/ and removes itself when git is done (the job module has the commands). The person’s own repository inside Work/, if there is one, is never touched: the backup has a git folder of its own, and git never takes a folder called .git into a snapshot.

Everything public here runs engine commands and waits for them, so it belongs on a background thread.

Modules§

conversations
The conversations backup: each profile’s conversations in a workspace, kept apart from the workspace’s own backup and brought back from any snapshot.

Structs§

BadPlace
A path that was refused, with why.
Entry
One snapshot in the list.
Place
A path inside Work/, checked, with / between its parts and no / at either end.
SnapshotId
The id of one snapshot: git’s commit id, in full.

Enums§

BackupError
Why a backup job did not do what was asked.
BackupEvery
How often an open workspace is backed up.
PlaceProblem
Why a path is not a place inside the workspace.
Reason
Why a snapshot was taken, kept as its commit message so the list can say it.
Restored
What restore and restore_file did.
Snapshot
What one round of snapshot did.

Functions§

assets_history
The snapshots of Assets/, newest first. Assets never backed up have none, and no container is started to say so.
history
The snapshots of the workspace, newest first; those that changed file when one is named. A workspace that has never been backed up has none, and no container is started to say so.
restore
Brings every file of the snapshot id back into the workspace, after a snapshot of how the workspace is now.
restore_assets
Brings every file of the snapshot id back into Assets/, after a snapshot of how it is now. Nothing is deleted, as in restore; a folder that is gone is made again to hold them.
restore_file
Brings file back as it was in the snapshot id, after a snapshot of how the workspace is now. The rest of the workspace is left as it is.
size
How much Backup/ holds on the disk, in bytes: every file under it, each counted once. A workspace never backed up holds nothing. A file that goes while it is counted is not counted; a symbolic link counts as itself, never as what it points to.
snapshot
Backs the workspace up, leaving out every folder or file of skip as well as what the workspace’s own .gitignore leaves out.
snapshot_assets
Backs Assets/ up, into a git folder of its own. A workspace without the folder has nothing to back up, and no container is started to say so.