mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 18:31:52 +00:00
* addHealthCheck on Daemons * fix bug that prevents domains without protocols from being deleted * fixes from testing * version bump * add sdk version to UI * fix useEntrypoint * fix dependency health check error display * minor fixes * beta.29 * fixes from testing * beta.30 * set /etc/os-release (#2918) * remove check-monitor from kiosk (#2059) * add units for progress (#2693) * use new progress type * alpha.7 * fix up pwa stuff * fix wormhole-squashfs and prune boot (#2964) * don't exit on expected errors * use bash --------- Co-authored-by: Matt Hill <mattnine@protonmail.com>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { Backups } from "./Backups"
|
|
import * as T from "../../../base/lib/types"
|
|
import { _ } from "../util"
|
|
import { InitScript } from "../../../base/lib/inits"
|
|
|
|
export type SetupBackupsParams<M extends T.SDKManifest> =
|
|
| M["volumes"][number][]
|
|
| ((_: { effects: T.Effects }) => Promise<Backups<M>>)
|
|
|
|
type SetupBackupsRes = {
|
|
createBackup: T.ExpectedExports.createBackup
|
|
restoreInit: InitScript
|
|
}
|
|
|
|
export function setupBackups<M extends T.SDKManifest>(
|
|
options: SetupBackupsParams<M>,
|
|
) {
|
|
let backupsFactory: (_: { effects: T.Effects }) => Promise<Backups<M>>
|
|
if (options instanceof Function) {
|
|
backupsFactory = options
|
|
} else {
|
|
backupsFactory = async () => Backups.ofVolumes(...options)
|
|
}
|
|
const answer: SetupBackupsRes = {
|
|
get createBackup() {
|
|
return (async (options) => {
|
|
return (await backupsFactory(options)).createBackup(options.effects)
|
|
}) as T.ExpectedExports.createBackup
|
|
},
|
|
get restoreInit(): InitScript {
|
|
return {
|
|
init: async (effects, kind) => {
|
|
return (await backupsFactory({ effects })).init(effects, kind)
|
|
},
|
|
}
|
|
},
|
|
}
|
|
return answer
|
|
}
|