brewlog/src/presentation/cli/backup.rs
Jon Seager 2ac61345ec
feat(backup): add CLI backup and restore commands
- Add BackupData struct and BackupService with raw SQL export/import
- Restore uses raw inserts to bypass brew deductions and timeline creation
- Restore requires an empty database, inserts in FK dependency order
- Add comprehensive e2e test verifying full round-trip fidelity
2026-02-03 12:50:41 +00:00

27 lines
594 B
Rust

use clap::Args;
#[derive(Debug, Args)]
pub struct BackupCommand {
/// Database URL to back up from
#[arg(
long,
env = "BREWLOG_DATABASE_URL",
default_value = "sqlite://brewlog.db"
)]
pub database_url: String,
}
#[derive(Debug, Args)]
pub struct RestoreCommand {
/// Database URL to restore into (must be an empty database)
#[arg(
long,
env = "BREWLOG_DATABASE_URL",
default_value = "sqlite://brewlog.db"
)]
pub database_url: String,
/// Path to the backup JSON file
#[arg(long)]
pub file: String,
}