Skip to content

๐Ÿ“ Watch-Sync: Real-time file synchronization tool that watches for changes and instantly syncs via FTP, SFTP, and rsync. Perfect for web developers maintaining remote servers, with smart directory structure preservation and flexible configuration options. โšก Simplify your workflow!

License

Notifications You must be signed in to change notification settings

erkineren/watch-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Watch-Sync

A Go console application that watches directories for changes and synchronizes them using various protocols (FTP, SFTP, Rsync).

Go Report Card License: MIT Go Version

Features

  • File System Watching: Monitors a directory for file/folder creation, modification, and deletion
  • Recursive Watching: Detects changes in subdirectories
  • Multiple Sync Methods:
    • FTP upload
    • SFTP upload
    • Rsync synchronization (preserves directory structure)
  • Configurable: Uses JSON configuration file stored in the user's home directory
  • Graceful Shutdown: Properly cleans up resources on exit
  • Ignores CHMOD Events: Avoids unnecessary syncs for permission changes

Installation

Using Go

# Clone the repository
git clone https://github.com/erkineren/watch-sync.git
cd watch-sync

# Build and install
make install

From Binary

Download the latest binary from the releases page.

Usage

# Watch the current directory with no actions
watch-sync

# Watch a specific directory
watch-sync -path /path/to/watch

# Watch with specific actions to trigger
watch-sync -actions prod-ftp,staging-sftp

# Watch a specific path with specific actions
watch-sync -path /path/to/watch -actions backup-rsync

# Watch without recursion (top level only)
watch-sync -recursive=false -actions prod-ftp

# Enable verbose logging
watch-sync -verbose -actions backup-rsync

Configuration

The configuration file is stored at ~/.watch-sync.json. If it doesn't exist, a default one will be created.

Example configuration:

{
  "actions": {
    "prod-ftp": {
      "type": "ftp",
      "settings": {
        "host": "ftp.example.com",
        "port": 21,
        "user": "username",
        "password": "password",
        "remote_dir": "/public_html"
      }
    },
    "staging-sftp": {
      "type": "sftp",
      "settings": {
        "host": "sftp.example.com",
        "port": 22,
        "user": "username",
        "password": "password",
        "key_file": "/path/to/private_key",
        "remote_dir": "/var/www"
      }
    },
    "backup-rsync": {
      "type": "rsync",
      "settings": {
        "host": "example.com",
        "user": "username",
        "remote_dir": "/var/www/html",
        "options": "-av --delete"
      }
    }
  },
  "filters": {
    "exclude": [".git", "node_modules", "*.tmp", "vendor", "*.log"]
  }
}

With this configuration, you can reference your actions by name when running the command:

watch-sync -actions prod-ftp,staging-sftp

Recent Improvements

  • Fixed rsync path preservation: rsync now correctly preserves directory structure on the remote server
  • Ignore CHMOD events: CHMOD events no longer trigger synchronization actions
  • Better error handling: Improved error logging and recovery

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Dependencies

  • fsnotify - Cross-platform file system notifications
  • sftp - SFTP client for Go
  • ftp - FTP client for Go

About

๐Ÿ“ Watch-Sync: Real-time file synchronization tool that watches for changes and instantly syncs via FTP, SFTP, and rsync. Perfect for web developers maintaining remote servers, with smart directory structure preservation and flexible configuration options. โšก Simplify your workflow!

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published