Coder Social home page Coder Social logo

totekuh / ssh-sync Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 2.0 6 KB

SSH Sync Folders is a simple and Bash script for syncing a local directory with a remote directory over SSH using rsync and inotifywait. The script monitors the local directory for changes and automatically syncs the updated files to the remote directory.

Makefile 30.39% Shell 69.61%
bash ssh makefile rsync sshpass sync syncronization

ssh-sync's Introduction

Description

A simple Bash script to sync a local directory with a remote directory over SSH using rsync and inotifywait.

The script sets up file watches on the local directory and automatically syncs any changes to the remote directory. If the initial sync fails due to permission issues or other errors, the script will not set up watches and will exit.

Usage

ssh-sync-folders [OPTIONS]

Options

  • -l, --local-dir=DIR: Local directory to be synced (default: current directory)
  • -u, --remote-user=USER: Remote SSH user
  • -p, --remote-pass=PASSWORD: Remote SSH password (optional)
  • -h, --remote-host=HOST: Remote SSH host
  • -d, --remote-dir=DIR: Remote directory to sync to (default: /shared)
  • -e, --exclude=PATTERNS: Comma-separated list of file/folder patterns to exclude

To display the help message, run the script with the --help option:

ssh-sync-folders --help

You can configure the script using environment variables or command-line options. Command-line options take precedence over environment variables.

Configure the following environment variables before running the script, unless you provide the options via command-line arguments:

  • SSH_SYNC_LOCAL_DIR: Local directory to be synced
  • SSH_SYNC_REMOTE_USER: Remote SSH user
  • SSH_SYNC_REMOTE_PASS: Remote SSH password (optional if using RSA keys)
  • SSH_SYNC_REMOTE_HOST: Remote SSH host
  • SSH_SYNC_REMOTE_DIR: Remote directory to sync to
  • SSH_SYNC_EXCLUDE_PATTERNS: Comma-separated list of file/folder patterns to exclude

Dependencies

  • rsync
  • inotify-tools
  • sshpass (optional, required if using a remote password)

Installation

A Makefile is included for easy installation and uninstallation.

To install the script, simply run:

make install

This will copy the script to /usr/bin and make it executable.

To uninstall the script, run:

make uninstall

To configure environment variables, run:

make configure

Example

ssh-sync-folders -l /path/to/local/dir -u remote_user -h remote_host -d /path/to/remote/dir -e ".git,*.log"

This command will sync /path/to/local/dir to /path/to/remote/dir on the remote host, excluding any .git directories and *.log files. The local directory will be watched for changes, and any modifications will be synced to the remote directory automatically.

ssh-sync's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.