/** * @file 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 | scheduled [--keep ] | verify | restore "); process.exitCode = 1; }