rustybackup
started as a small learning scaffold and now demonstrates a simple
incremental backup workflow implemented in Rust.
The command line interface can scan configured directories, copy changed files to a destination, manage historical versions and record the most recent backup state. Configuration is loaded from a TOML file.
- Command line interface built with
clap
- Configuration parsed with
serde
andtoml
scan
shows files changed since the last backup while honoring exclude patternsbackup
copies changed files, keeps prior versions in aHistory
folder and can resume if interruptedvacuum
andstatus
subcommands are placeholders for future features- Persistent
state.toml
tracks snapshot IDs and records transfer statistics for each snapshot - Stub module for reading the NTFS USN change journal on Windows
- Install Rust from rustup.rs.
- Build the project with
cargo build
. - Run a command, e.g.
cargo run -- --config config.toml scan
. - Execute the test suite with
cargo test
.
src/main.rs
- entry point and CLI definitionssrc/lib.rs
- library exports used by testssrc/config.rs
- configuration structuressrc/state.rs
- persistent backup state trackingsrc/backup.rs
- scanning and backup logicsrc/journal.rs
- changed file detection helperstests/
- integration and unit tests
Settings are loaded from a config.toml
file. The file is divided into
[paths]
and [backup]
sections:
[paths]
include = ["src"] # directories to scan
exclude = ["*/temp"] # optional glob patterns to ignore
[backup]
destination = "backups" # where backup data and state are stored
keep_versions = true # keep previous versions under a `History` folder
max_versions = 5 # limit history depth when set
Field descriptions:
- paths.include: directories that will be scanned for changed files.
- paths.exclude: list of patterns to skip during scanning.
- backup.destination: directory that receives the synchronized files and
state.toml
. - backup.keep_versions: if
true
, prior versions of modified files are preserved in aHistory
folder. - backup.max_versions: optional maximum number of versions to keep when
keep_versions
is enabled.
See tests/test_config.toml
for a minimal working example.
state.toml
stores metadata about the latest and previous backups. Each item in
the stats
array records:
timestamp
– when the backup completedsnapshot_id
– monotonically increasing identifierfiles_synced
– count of files copiedbytes_copied
– total bytes transferredduration_ms
– runtime in milliseconds