Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

📁 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

NotificationsYou must be signed in to change notification settings

erkineren/watch-sync

Repository files navigation

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

Go Report CardLicense: MITGo 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 repositorygit clone https://github.com/erkineren/watch-sync.gitcd watch-sync# Build and installmake install

From Binary

Download the latest binary from thereleases page.

Usage

# Watch the current directory with no actionswatch-sync# Watch a specific directorywatch-sync -path /path/to/watch# Watch with specific actions to triggerwatch-sync -actions prod-ftp,staging-sftp# Watch a specific path with specific actionswatch-sync -path /path/to/watch -actions backup-rsync# Watch without recursion (top level only)watch-sync -recursive=false -actions prod-ftp# Enable verbose loggingwatch-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 theLICENSE 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

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp