Rust CLI that synchronizes a local folder with a git repository in either push or pull mode.
- Push mode: sync local files to a repository branch
- Pull mode: sync repository files to a local folder
- Private repository support via your existing git/SSH configuration
- Optional custom SSH key via
GIT_SSH_COMMANDconstruction - Git SSH commands run non-interactively (
StrictHostKeyChecking=accept-new,CheckHostIP=no) to skip host key prompts - Size-based log rotation (10MB, keep 3 files) logging to both stdout and
file-syncer.log - Skips the
.gitdirectory during sync - Generates commit messages based on detected file changes
- Optional zstd compression that stores files as
*-zstdin the repository
- Rust 1.74 or later
- Git
git clone https://github.com/rikkicom/file-syncer.git
cd file-syncer
cargo build --releaseBuild musl binaries with zig (x86_64 and aarch64):
cargo install cargo-zigbuild --locked
cargo zigbuild --release --target x86_64-unknown-linux-musl
cargo zigbuild --release --target aarch64-unknown-linux-muslfile-syncer --mode <push|pull> --folder <path> --repo <url> [--branch <branch>] [--ssh-key <path>] [--compress] [--compression-fast|--compression-default|--compression-max]
Run directly from source:
cargo run -- --mode push --folder ./myfiles --repo https://github.com/user/repo.gitInstalled binary:
cargo install --path .
file-syncer --mode pull --folder ./myfiles --repo https://github.com/user/repo.git --branch developCompress files during sync (they are stored as *-zstd in the repository and restored to the original names when pulling). Choose a level with the flags below; default is --compression-default:
file-syncer --mode push --folder ./data --repo https://github.com/user/repo.git --compress --compression-max
file-syncer --mode pull --folder ./data --repo https://github.com/user/repo.git --compress --compression-max# First time: push files to a new repository
file-syncer --mode push --folder ~/documents --repo https://github.com/yourusername/my-backup.git
# Later: push updates
file-syncer --mode push --folder ~/documents --repo https://github.com/yourusername/my-backup.gitOn machine 1:
file-syncer --mode push --folder ~/projects/shared --repo https://github.com/yourusername/shared-files.gitOn machine 2:
file-syncer --mode pull --folder ~/projects/shared --repo https://github.com/yourusername/shared-files.git# Push with a specific SSH key (useful for deployment keys or multiple accounts)
file-syncer --mode push --folder ~/backups --repo git@github.com:yourusername/backup-repo.git --ssh-key ~/.ssh/deployment_key
# Pull with a specific SSH key
file-syncer --mode pull --folder ~/restore --repo git@github.com:yourusername/backup-repo.git --ssh-key ~/.ssh/deployment_keyThe application supports both public and private repositories. For private repositories, ensure your system is configured with appropriate git credentials:
# Use SSH URL format with system default SSH key
file-syncer --mode push --folder ./myfiles --repo git@github.com:yourusername/private-repo.git
# Or specify a custom SSH key
file-syncer --mode push --folder ./myfiles --repo git@github.com:yourusername/private-repo.git --ssh-key ~/.ssh/custom_id_rsa# Configure git credential helper (one-time setup)
git config --global credential.helper store
# Or use GitHub CLI for authentication
gh auth login
# Then use HTTPS URL
./file-syncer -mode push -folder ./myfiles -repo https://github.com/yourusername/private-repo.gitFor HTTPS URLs, you can embed credentials or use a credential helper. The application inherits all git configuration from your system.
Logs are emitted to stdout and file-syncer.log with size-based rotation (10MB, keep 3 rotated files). The log format is the default provided by flexi_logger.
Logs are written to the current working directory.
Optional Sentry error reporting is available. Provide a DSN via --sentry-dsn or the SENTRY_DSN environment variable. When configured, panics and fatal errors are reported before the process exits.
Run the unit tests:
cargo testIntegration tests (use the real git binary) are behind a feature flag:
cargo test --features integration