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>
21 lines
1.4 KiB
JavaScript
21 lines
1.4 KiB
JavaScript
// Rôle : sauvegarde ou vérifie la base Sokko TCG depuis les tâches d'exploitation.
|
|
import { resolve } from "node:path";
|
|
import { backupCardsDatabase, restoreCardsDatabase, runScheduledBackup, verifyCardsDatabase } from "../services/cards/backup.js";
|
|
|
|
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)}`);
|
|
} else if (mode === "restore" && 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> | scheduled <database> <directory> [--keep <count>] | verify <backup> | restore <backup> <database>");
|
|
process.exitCode = 1;
|
|
}
|