Schedules, retention and the repository
Backups taken by hand are for the moment before a change. The rest come from
a schedule. A schedule belongs to a scope: one deployment, an environment, a
tenant or the whole cluster, and the narrowest one that matches a deployment
wins. Typed alone, shc backup schedule lists its verbs.
$ shc backup schedule...$ shc backup schedule set "30 3 * * *" -s notebook...$ shc backup schedule set "@daily" --scope tenant...$ shc backup schedule ls...run fires a scope’s schedule now, through the same path the clock takes.
Like a backup by hand it can take the deployment’s integration graph or its
dependants too.
$ shc backup schedule run -s notebook...$ shc backup schedule run --scope deployment -s notebook --all-connected...$ shc backup schedule run --scope deployment -s notebook --with-dependants...$ shc backup schedule set "@hourly" --scope deployment -s notebook --all-connected --with-dependants...$ shc backup schedule unset --scope tenant...$ shc backup schedule ls...Retention
Section titled “Retention”Retention decides how many backups a scope keeps: so many dailies, weeklies,
monthlies and yearlies, counted back from the newest. shc retention alone
prints the policy that applies.
$ shc retention -s notebook...$ shc retention ls...$ shc retention set -s notebook --daily 2 --weekly 1 --monthly 1 --yearly 0...$ shc retention preview -s notebook...preview lists what the policy would delete and deletes nothing. apply
deletes it. reset writes the shipped defaults back as the scope’s policy;
nothing is deleted until the next apply.
$ shc retention apply -s notebook --yes...$ shc backup ls -s notebook...$ shc retention reset -s notebook...A backup can also go by hand, and prune then frees the repository data no
backup refers to any more. Take two and remove one; kept is read again
after the key rotation below.
$ shc backup create notebook --name kept...$ shc backup create notebook --name scratch...$ shc backup rm scratch -s notebook --yes...$ shc backup prune --yes...ls --all-tenants is the whole cluster’s list, for an operator of every
tenant.
$ shc backup ls --all-tenants --limit 5...Moving the repository
Section titled “Moving the repository”Each backup records the repository it lives in, so moving the repository takes two steps: point the cluster at the new place, then rewrite the records. Copy the repository, then do both.
$ cp -a /var/backups/shc/repo /var/backups/shc/moved$ shc config set backup.repo /var/backups/shc/moved --scope global...$ shc backup relocate --from /var/backups/shc/repo --to /var/backups/shc/moved --dry-run...$ shc backup relocate --from /var/backups/shc/repo --to /var/backups/shc/moved --skip-missing --yes...$ shc backup ls -s notebook...relocate refuses, writing nothing, unless the new repository holds every
snapshot the records name. --skip-missing moves only the records whose
snapshot it holds, for a copy that is behind. sync reads a repository’s
snapshots into the cluster’s list, which is how backups another cluster wrote
into a shared repository show up here.
$ shc backup sync -s notebook...$ shc backup prune --repo /var/backups/shc/repo --yes...The repository’s key
Section titled “The repository’s key”The key that opens the repository is in the vault. rotate re-keys every
repository it opens in one step: the new key is added before the old one is
removed, and no backup is encrypted again. By default it makes a key; a file
of your own works too. Typed alone, shc backup key lists its verbs.
learn-backup-key-0002$ shc backup key...$ shc backup key ls...$ shc backup key rotate --yes...$ chmod 600 ~/learn/backup.key$ shc backup key rotate --new-key-file ~/learn/backup.key --repo /var/backups/shc/moved --yes...$ shc backup key ls --repo /var/backups/shc/moved...$ shc backup verify kept -s notebook...A rotation interrupted half way leaves both keys able to open the
repository. key rm retires the one left over; it never removes the key it
opened the repository with.
$ shc backup key rm 4f1c2a9e --repo /var/backups/shc/moved --yesAfter a failed restore
Section titled “After a failed restore”A restore marks the deployment it replayed, and while the mark stands SHC refuses any job that would seed the app from scratch over the restored data. A restore lifts its own mark once the data is back. A recover that failed half way leaves a deployment empty and stamped unusable, so it never passes for a good one. Both are cleared on the node the deployment lives on, once you have checked the data by hand.
$ shc backup clear-restore-seal -s notebook --yes...$ shc backup clear-unusable -s notebook --yes...Three things this ladder does not run: splitting a .bkg back into its
backups, which needs the group’s id, importing an archive whose size field an
old writer clamped, and mounting a .bak directly, which is not built yet.
A backup mount is read-only.
$ shc backup ungroup 7d2e41c0$ shc backup import --repair-container /var/lib/shc/dr/notebook.bak$ shc backup mount ~/learn/snapshot --file ~/learn/handover/notebook.bakNext: Exporters.