mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 18:31:52 +00:00
* fix master build (#2639) * feat: Change ts to use rsync Chore: Update the ts to use types over interface * feat: Get the rust and the js to do a backup * Wip: Got the backup working? * fix permissions * remove trixie list * update tokio to fix timer bug * fix error handling on backup * wip * remove idmap * run restore before init, and init with own version on restore --------- Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com> Co-authored-by: Aiden McClelland <me@drbonez.dev>
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { Backups } from "./Backups"
|
|
import { SDKManifest } from "../manifest/ManifestTypes"
|
|
import { ExpectedExports, PathMaker } from "../types"
|
|
import { _ } from "../util"
|
|
|
|
export type SetupBackupsParams<M extends SDKManifest> = Array<
|
|
M["volumes"][number] | Backups<M>
|
|
>
|
|
|
|
export function setupBackups<M extends SDKManifest>(
|
|
...args: _<SetupBackupsParams<M>>
|
|
) {
|
|
const backups = Array<Backups<M>>()
|
|
const volumes = new Set<M["volumes"][0]>()
|
|
for (const arg of args) {
|
|
if (arg instanceof Backups) {
|
|
backups.push(arg)
|
|
} else {
|
|
volumes.add(arg)
|
|
}
|
|
}
|
|
backups.push(Backups.volumes(...volumes))
|
|
const answer: {
|
|
createBackup: ExpectedExports.createBackup
|
|
restoreBackup: ExpectedExports.restoreBackup
|
|
} = {
|
|
get createBackup() {
|
|
return (async (options) => {
|
|
for (const backup of backups) {
|
|
await backup.build(options.pathMaker).createBackup(options)
|
|
}
|
|
}) as ExpectedExports.createBackup
|
|
},
|
|
get restoreBackup() {
|
|
return (async (options) => {
|
|
for (const backup of backups) {
|
|
await backup.build(options.pathMaker).restoreBackup(options)
|
|
}
|
|
}) as ExpectedExports.restoreBackup
|
|
},
|
|
}
|
|
return answer
|
|
}
|