This tool continuously monitors a source directory (e.g., an Active Directory or network share) for changes to a trigger file (parts.json
) and automatically synchronizes files to a destination directory.
It is designed for reliability, with safe copy operations, retry logic, logging, and low-disk-space notifications (via Windows toast).
- 🔄 Automatic sync when
parts.json
is created or updated - 🛡 Safe copy with retries (temp files, atomic rename, error handling)
- ⚡ Change detection (size, modification time, or optional MD5 hash check)
- 💾 Low disk space warning (Windows toast notification when free space < 5%)
- 📜 Logging to console +
logs/YYYY-MM-DD_HH-MM-SS.log
- ⚙️ Configurable source/destination via CLI flags
- ✅ Designed for Windows environments with network shares
Clone the repo and build:
git clone https://github.com/BaseMax/auto-copy-from-active-directory
cd auto-copy-from-active-directory
go build -o FileSyncApp.exe
By default:
- Source:
\\192.168.1.200\max
- Destination:
D:\Sync
Run:
FileSyncApp.exe
You can override with flags:
FileSyncApp.exe --src="E:\Projects" --dest="F:\Backup"
--src
→ Source directory (default:\\192.168.1.200\max
)--dest
→ Destination directory (default:D:\Sync
)
All actions are logged to:
logs/2025-08-18_12-30-00.log
with timestamps, plus real-time console output.
If the destination drive has less than 5% free space, a Windows toast notification appears:
Low Disk Space Warning
Destination drive is almost full (xx% free). Consider freeing up space.
- On startup, performs a full sync of
src → dest
. - Watches for changes to
parts.json
in the source directory. - When
parts.json
is updated or recreated, re-syncs files. - Uses safe copy: write to
.tmp
, flush to disk, retry remove/rename. - Optionally checks MD5 hashes to detect changes.
MIT License Copyright (c) 2025 Max Base
See LICENSE for details.