ReBackup program
ReBackup is a simple backup program that doesn't actually create backups but instead creates a list of files to backup from a source directory.
It uses a walker to traverse filesystem items, which can be customized through rules (see [WalkerRule
]).
Its main features are:
- Fast recursive directory traversing
- Powerful rules system to include, exclude or remap items
- Handling of symbolic links (requires to enable an option for the walker)
- Detection of already visited paths
- Command-line interface
ReBackup can be used either:
- As a library (see
walk
) - As a standalone binary with the
cli
feature
Library usage
ReBackup only exports one single function which is the Walker: walk
.
It can be used like this:
use PathBuf;
use ;
let source = args.nth
.unwrap_or_else;
// NOTE: This can be shortened to `WalkerConfig::new(vec![])`
// (expanded here for explanations purpose)
let config = WalkerConfig ;
let files_list = walk
.unwrap_or_else;
let files_list_str: = files_list
.iter
.map
.collect;
println!;
Rules
You can use powerful rules to configure how the walker behaves.
A rule is defined using [WalkerRule
], and uses two callbacks:
- One to determine if the rule applies on a specific item
- One to run the rule itself
Here is a basic rule excluding all directories containing .nomedia
files:
use *;
let rule = WalkerRule ;
You can also build more powerful rules, like excluding files ignored by Git:
use env;
use Command;
use *;
let rule = WalkerRule ;
You can check more examples of rules in examples/rules.rs
.
Command-line usage
# Build the list of files to backup, and pipe it to 'tar'
# to create a compressed archive
# Be aware of not creating the archive inside the directory to backup, or the archive
# will be listed as well (you can still exclude it from the results afterwards)
rebackup path_to_backup/ | tar -czf output.tgz -T -
# If you are in another directory, ask for absolute paths instead
# Please note that the archive's content will have absolute paths as well
rebackup path_to_backup/ -a | tar -czf output.tgz -T -
# Using filters to exclude items based on patterns
# Here we're excluding all items ignored by the '.gitignore' file in Git repositories
rebackup path_to_backup/ -f '! git check-ignore "$REBACKUP_ITEM"'
# To also exclude the ".git" folder (using glob pattern):
rebackup path_to_backup/ -f '! git check-ignore "$REBACKUP_ITEM"' -e '**/.git'
# Use an alternate shell:
rebackup path_to_backup/ -f '! git check-ignore "$REBACKUP_ITEM"' --shell zsh --shell-head-args=-c
# To list all available arguments:
rebackup --help
License
This project is released under the Apache-2.0 license terms.