envelope_cli/backup/
mod.rs

1//! Backup system for EnvelopeCLI
2//!
3//! Provides automatic rolling backups with configurable retention policies
4//! and restore functionality.
5//!
6//! # Architecture
7//!
8//! The backup system consists of two main components:
9//!
10//! - `BackupManager`: Creates and manages backups with retention policies
11//! - `RestoreManager`: Validates and restores backups
12//!
13//! # Backup Format
14//!
15//! Backups are stored as JSON files with the following structure:
16//! - `schema_version`: Version for migration support
17//! - `created_at`: Timestamp when backup was created
18//! - `accounts`: Account data
19//! - `transactions`: Transaction data
20//! - `budget`: Categories, groups, and allocations
21//! - `payees`: Payee data
22//!
23//! # Retention Policy
24//!
25//! By default, the system keeps:
26//! - 30 daily backups
27//! - 12 monthly backups (first backup of each month)
28//!
29//! # Example
30//!
31//! ```rust,ignore
32//! use envelope::backup::{BackupManager, RestoreManager};
33//! use envelope::config::{paths::EnvelopePaths, settings::BackupRetention};
34//!
35//! // Create a backup
36//! let paths = EnvelopePaths::new()?;
37//! let retention = BackupRetention::default();
38//! let backup_manager = BackupManager::new(paths.clone(), retention);
39//!
40//! let backup_path = backup_manager.create_backup()?;
41//! backup_manager.enforce_retention()?;
42//!
43//! // Later, restore from backup
44//! let restore_manager = RestoreManager::new(paths);
45//! let result = restore_manager.restore_from_file(&backup_path)?;
46//! println!("{}", result.summary());
47//! ```
48
49mod manager;
50mod restore;
51
52pub use manager::{BackupArchive, BackupInfo, BackupManager};
53pub use restore::{ExportRestoreCounts, RestoreManager, RestoreResult, ValidationResult};