Skip to content

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).

License

Notifications You must be signed in to change notification settings

BaseMax/auto-copy-from-active-directory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto Copy from Active Directory

License: MIT

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).


✨ Features

  • 🔄 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

🚀 Installation

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

⚙️ Usage

Default behavior

By default:

  • Source: \\192.168.1.200\max
  • Destination: D:\Sync

Run:

FileSyncApp.exe

Custom source/destination

You can override with flags:

FileSyncApp.exe --src="E:\Projects" --dest="F:\Backup"

Flags

  • --src → Source directory (default: \\192.168.1.200\max)
  • --dest → Destination directory (default: D:\Sync)

📂 Logs

All actions are logged to:

logs/2025-08-18_12-30-00.log

with timestamps, plus real-time console output.


🖥 Notifications

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.

🔧 How it Works

  1. On startup, performs a full sync of src → dest.
  2. Watches for changes to parts.json in the source directory.
  3. When parts.json is updated or recreated, re-syncs files.
  4. Uses safe copy: write to .tmp, flush to disk, retry remove/rename.
  5. Optionally checks MD5 hashes to detect changes.

📜 License

MIT License Copyright (c) 2025 Max Base

See LICENSE for details.

About

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).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages