Make Cards database restores reliable and schedule backups
A restore left the replaced database's write-ahead log in place, so SQLite replayed it and the restored file silently kept later writes. Restores now remove it, backups stay single files, and a systemd timer keeps 14 daily copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d72dd38317
commit
115e62d5b2
5 changed files with 118 additions and 8 deletions
|
|
@ -1,11 +1,14 @@
|
|||
// Rôle : sauvegarde ou vérifie la base Sokko TCG depuis les tâches d'exploitation.
|
||||
import { resolve } from "node:path";
|
||||
import { backupCardsDatabase, restoreCardsDatabase, verifyCardsDatabase } from "../services/cards/backup.js";
|
||||
import { backupCardsDatabase, restoreCardsDatabase, runScheduledBackup, verifyCardsDatabase } from "../services/cards/backup.js";
|
||||
|
||||
const [mode, source, destination] = process.argv.slice(2);
|
||||
const [mode, source, destination, keepFlag, keepValue] = process.argv.slice(2);
|
||||
if (mode === "backup" && source && destination) {
|
||||
await backupCardsDatabase(resolve(source), resolve(destination));
|
||||
console.log(`Sokko TCG backup written to ${resolve(destination)}`);
|
||||
} else if (mode === "scheduled" && source && destination && (!keepFlag || keepFlag === "--keep")) {
|
||||
const written = await runScheduledBackup(resolve(source), resolve(destination), keepFlag ? { keep: Number(keepValue) } : {});
|
||||
console.log(`Sokko TCG scheduled backup written to ${written}`);
|
||||
} else if (mode === "verify" && source) {
|
||||
verifyCardsDatabase(resolve(source));
|
||||
console.log(`Sokko TCG backup verified: ${resolve(source)}`);
|
||||
|
|
@ -13,6 +16,6 @@ if (mode === "backup" && source && destination) {
|
|||
restoreCardsDatabase(resolve(source), resolve(destination));
|
||||
console.log(`Sokko TCG database restored to ${resolve(destination)}`);
|
||||
} else {
|
||||
console.error("Usage: node scripts/backup-nebula-cards.mjs backup <database> <backup> | verify <backup> | restore <backup> <database>");
|
||||
console.error("Usage: node scripts/backup-nebula-cards.mjs backup <database> <backup> | scheduled <database> <directory> [--keep <count>] | verify <backup> | restore <backup> <database>");
|
||||
process.exitCode = 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue