SyncFile Format
Master the powerful SyncFile format for declarative sync operations.
SyncFile Format
sync-tools introduces a powerful SyncFile format — a Dockerfile-inspired declarative syntax for complex sync operations.
Basic Syntax
A SyncFile uses simple, declarative syntax to define multiple sync operations, filters, and configurations in a single file.
Example SyncFile
| |
Instructions Reference
| Instruction | Description | Example |
|---|---|---|
SYNC source dest [options] | Define a sync operation | SYNC ./src ./backup --dry-run |
MODE one-way|two-way | Set sync mode | MODE two-way |
EXCLUDE pattern | Exclude files/folders | EXCLUDE *.tmp |
INCLUDE pattern | Include files (unignore) | INCLUDE !important.tmp |
ONLY pattern | Whitelist mode | ONLY *.go |
DRYRUN true|false | Enable/disable dry run | DRYRUN true |
PATCH filename | Generate git patch file | PATCH changes.patch |
APPLYPATCH true|false | Apply patch after creation | APPLYPATCH true |
PREVIEW true|false | Show colored diff preview | PREVIEW true |
AUTOCONFIRM true|false | Auto-confirm patch application | AUTOCONFIRM true |
GITIGNORE true|false | Use .gitignore patterns | GITIGNORE true |
HIDDENDIRS exclude|include | Handle hidden directories | HIDDENDIRS exclude |
VAR name=value | Define variable | VAR BASE=/home/user |
ENV name=value | Environment variable | ENV RSYNC_OPTS=--progress |
# comment | Comments | # Sync documentation |
Variables can be referenced using ${name} or $name syntax.
Execution
Execute Default SyncFile
| |
Advanced Examples
Multi-Environment Sync
| |
Workflow with Multiple Patches
| |
Configuration Priority
When using SyncFiles with CLI flags, the priority order is:
- Command-line flags (highest priority)
- SyncFile instructions
- TOML configuration file
- Default values (lowest priority)
SyncFile Discovery
sync-tools looks for SyncFiles in this order:
- Specified file:
sync-tools syncfile my-file.sf SyncFileSyncfilesyncfile.syncfile
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.