Archive the whole data volume in Backups, not just the database
Settings > Backups gains a whole-data archive beside the database snapshots, and both lists now fully work from the page. - Data archives: `write-data-backup-archive.ts` tars all of DATA_DIR into BACKUP_ARCHIVE_DIR as cobble-data-<epoch-ms>.tar.gz, every entry under one root folder named after the archive, writing a .part name and renaming on success so a cut-off run is never listed. The newest AppData.DataBackupsKept are kept; db/.backups is left as it is. - Restore: `restore-data-backup.ts` extracts to a temp dir, requires one root folder holding a db folder, takes a safety archive first, then replaces DATA_DIR (the database snapshots included) and `restart-app.ts` restarts the process through the docker socket, since the open SQLite handle points at the replaced file. - Upload and restore: a modal over each list (database file or data archive), replacing the old /admin/settings/backups/restore page. - Delete for both kinds, icon-only row actions shared through RowIconButton, and restore on every row. - One backup or restore of either kind at a time (with-backup-run-lock). - BACKUP_ARCHIVE_DIR is a start-up path (ProcessOnlyEnvKeys); the installer mounts $COBBLE_HOME/backups-archives at /backups-archives and recreates a container that lacks it. The image installs tar and gzip.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import fs from "fs";
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
|
||||
/**
|
||||
* Absolute path of the directory the whole-data archives are written to.
|
||||
* It is deliberately outside `DATA_DIR` (an archive must never contain
|
||||
* other archives) and outside the database's own `db/.backups`
|
||||
* directory, which keeps its bun-sqlite snapshots.
|
||||
*
|
||||
* `BACKUP_ARCHIVE_DIR` is the container's or install's setting (the
|
||||
* installer mounts `/backups-archives` from `$COBBLE_HOME/backups-archives`);
|
||||
* outside docker it falls back to `~/.cobble/backups`. It is a start-up
|
||||
* path like `DATA_DIR`, so it stays in the process environment and is
|
||||
* never an `envs` row.
|
||||
*/
|
||||
export default function grabBackupArchiveDir() {
|
||||
const dir =
|
||||
process.env.BACKUP_ARCHIVE_DIR ||
|
||||
path.join(os.homedir(), ".cobble", "backups");
|
||||
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
|
||||
return path.resolve(dir);
|
||||
}
|
||||
Reference in New Issue
Block a user