One-way file synchronization tool written in Go. Supports local and remote (SFTP) directories.
go build -o sync ./cmd/syncmake builddocker build -t sync:latest ../sync [options] <source> <target><source>- Source directory path or[user@]host:/pathfor remote (required)<target>- Target directory path or[user@]host:/pathfor remote (required)
-d, --delete-missing- Delete files in target that don't exist in source-c, --checksum- Compare files using SHA256 checksum (slower but more accurate)-i, --identity FILE- Path to SSH private key (default:~/.ssh/id_ed25519,~/.ssh/id_rsa)-p, --port PORT- SSH port (default: 22)--password PASS- SSH password (prefer key-based auth)-h, --help- Show help message
# Basic synchronization
./sync /path/to/source /path/to/target
# Delete files in target that don't exist in source
./sync -d /path/to/source /path/to/target
# Use SHA256 checksum for comparison (more accurate)
./sync -c /path/to/source /path/to/target
# Combine flags
./sync -d -c /path/to/source /path/to/target# Push local files to remote server
./sync /local/path user@host:/remote/path
# With custom SSH key and port
./sync -i ~/.ssh/my_key -p 2222 /local/path user@host:/remote/path# Pull remote files to local directory
./sync user@host:/remote/path /local/path# Sync between two remote servers
./sync user@host1:/path user@host2:/path# Run with mounted volumes
docker run --rm \
-v /path/to/source:/source:ro \
-v /path/to/target:/target \
sync:latest /source /target
# With delete-missing flag
docker run --rm \
-v /path/to/source:/source:ro \
-v /path/to/target:/target \
sync:latest -d /source /target- Scans the source directory recursively
- For each file in source:
- If file doesn't exist in target → copy
- If file exists → compare (by size/modtime or SHA256 checksum) → update if different
- If
--delete-missingis enabled:- Scans target directory
- Deletes files that don't exist in source
- Default (metadata): Compares file size and modification time. Fast but may miss files with same size/time but different content.
- Checksum (
-c): Compares SHA256 hash of file contents. Slower but guarantees detection of any content difference.
When using remote paths ([user@]host:/path), the tool connects via SFTP over SSH. Authentication methods are tried in this order:
- Password — if provided via
--passwordflag - SSH agent — if
SSH_AUTH_SOCKis set - Private key — from
--identityflag, or defaults:~/.ssh/id_ed25519,~/.ssh/id_rsa
Host key verification uses ~/.ssh/known_hosts when available.
make build # Build binary for current platform
make test # Run tests
make clean # Remove build artifacts
make build-docker # Build Docker image
make build-all # Build multi-platform Docker images (requires buildx)
make dist # Build binaries for all platformsBuild binaries for all supported platforms:
make distThis creates binaries in dist/ directory:
sync-linux-amd64sync-linux-arm64sync-darwin-amd64sync-darwin-arm64sync-windows-amd64.exe
Build Docker images for multiple platforms using buildx:
make build-allSupported platforms:
linux/amd64linux/arm64darwin/amd64darwin/arm64windows/amd64
go test ./...
# or
make test