A Rust utility to compress folders into ZIP archives with support for file and folder exclusions, and optional Dropbox upload functionality.
- Recursive folder compression: Compress entire directory trees into ZIP archives
- Flexible exclusion system: Exclude specific files and folders using patterns
- Wildcard support: Use patterns like
*.tmp
,temp*
, or*cache*
to exclude files - Automatic timestamping: Generated archives include timestamp in filename
- Cross-platform compatibility: Works on Windows, macOS, and Linux
- Dropbox integration: Optional upload to Dropbox (requires configuration)
- Rust 1.70 or later
- Cargo package manager
- Clone the repository:
git clone https://github.com/lucabertani/backup-rs.git
cd backup-rs
- Build the project:
cargo build --release
- The executable will be available in
target/release/backup-rs
(orbackup-rs.exe
on Windows)
The application uses a YAML configuration file to define folders to backup and exclusion rules.
Create a config.yaml
file in the configs/
directory:
folders:
- path: "/path/to/your/folder"
exclude_folders:
- "node_modules"
- ".git"
- "target"
- "dist"
exclude_files:
- "*.tmp"
- "*.log"
- ".DS_Store"
- "Thumbs.db"
- "*.exe"
dropbox:
api_key: "your_dropbox_app_key"
token: "your_dropbox_access_token"
path
: The absolute or relative path to the folder you want to backupexclude_folders
: List of folder names/paths to exclude (relative to the main path)exclude_files
: List of file patterns to exclude (supports wildcards)
api_key
: Your Dropbox application keytoken
: Your Dropbox access token
Run the application with default configuration:
./backup-rs
This will:
- Read the configuration from
configs/config.yaml
- Create ZIP archives for each configured folder
- Save archives in the
archive/
directory - Upload to Dropbox if configured
Archives are automatically named using the format:
<folder_name>_YYYYMMDD_HHMMSS.zip
For example: my_project_20250726_143022.zip
The exclusion system supports various patterns:
node_modules
- Excludes any folder named "node_modules".git
- Excludes Git repository folderstarget
- Excludes Rust build artifacts
*.tmp
- Excludes all files ending with .tmptemp*
- Excludes all files starting with "temp"*cache*
- Excludes all files containing "cache".DS_Store
- Excludes macOS system filesThumbs.db
- Excludes Windows thumbnail files
folders:
- path: "/home/user/my_project"
exclude_folders:
- "node_modules"
- ".git"
- "dist"
- "build"
exclude_files:
- "*.log"
- "*.tmp"
- ".env"
This configuration will:
- Backup the entire
/home/user/my_project
folder - Skip
node_modules
,.git
,dist
, andbuild
folders - Skip log files, temporary files, and environment files
folders:
- path: "/home/user/documents"
exclude_files:
- "*.tmp"
- ".DS_Store"
- path: "/home/user/photos"
exclude_folders:
- ".thumbnails"
exclude_files:
- "*.raw"
- "Thumbs.db"
folders:
- path: "/important/data"
exclude_folders:
- "cache"
exclude_files:
- "*.log"
dropbox:
api_key: "your_app_key_here"
token: "your_access_token_here"
To enable Dropbox uploads:
- Go to Dropbox App Console
- Create a new app or use an existing one
- Get your App Key and generate an access token
- Add the credentials to your
config.yaml
file
Note: The current implementation uses long-lived access tokens. For production use, consider implementing OAuth2 flow for better security.
The application will:
- Create an
archive/
directory if it doesn't exist - Generate ZIP files with timestamps
- Display progress information during compression
- Show file sizes and compression results
- Upload to Dropbox if configured
The application provides detailed error messages for common issues:
- Invalid configuration files
- Missing directories
- Permission errors
- Dropbox upload failures
- Insufficient disk space
- Large folders may take significant time to compress
- Memory usage scales with the largest individual file size
- Compression level is optimized for balance between speed and size
- Excluded folders are skipped entirely, improving performance
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License. See LICENSE file for details.
- Initial release
- Basic ZIP compression functionality
- File and folder exclusion support
- Dropbox upload integration
- Cross-platform support