GitHub - kevintruong/workspace-rsync: Working space rsync utility. The utility tool will monitor your working space and rsync with your remote work space. The update will automatic update from local to remote side

3 min read Original article ↗

What is Workspace Rsync ?

https://i.imgur.com/46uSknN.gif

Simple and lightweight bash script can help to quick sync a change from local workspace to remote workspace. , support to upload resource to and download resource from remote workspace. Another useful of the tool is support to quickly run command on remote workspace.

Features:

  • Automatically sync up my local working space (directories) to remote working space

    • Configure your local working directories

    • Configure your remote working directories

    • configure ssh account with private key to use rsync/scp for download/update files

    • Inotify/monitoring changing happend in your local working dir and update to remote working dir

  • Support to sync up the whole working dir from remote to local and otherwise

  • Support configure file for auto-reload the previous configure

  • Saving the configure file to <Local Workspace>/.ws-rsync, Auto apply the configuration from there when user run the utility on configured workspace

  • If the local has not the workspace matching with remote side, then ask user to allow for downloading the remote side. And otherwise. if remote has not the Workspace which existed on local, the ask user to allow for uploading the local version to remote. But I will follow the simple methology here that Remote Side always have the latest version, The local will always clone workspace from remote side.

  • Support local rsync. In the case, don’t need push any infomation in --ssh-acc/--ssh-pass/--ssh-key , the ws-rsync will becall in local

  • Support remote command call : Run command on remote

Getting start

Install

Ideally, the utility is not dependency on any other tools. But if your remote side is not support private key/public key pair for authentication then you should use ssh password for authentication. Then you need sshpass

Another side is how the ws-rsync daemon know about there have a changed/create file. I used find with diff_time pooling mechanism to check the status of files in local side. But there will have window time diff_time to the next check If you want the process more realtime, then you need inotify-tools

#dependency to run ssh with password authentication
sudo apt install sshpass inotify-tools

sudo make install

Configure and run the utility

# for use ssh key to authentication
ws-rsync init
ws-rsync config
ws-rsync start

Sub-Commands

Force download from remote

ws-rsync download <workspace_file_path>
  • Example:

ws-rsync download /home/kevin/Project/KEVIN/Workspace/KenCanCode/version.h
ws-rsync download ./version.h

Upload to remote workspace

Upload workspace_file_path to remote, support relative/absolute path

ws-rsync upload <workspace_file_path>
  • Example:

ws-rsync upload /home/kevin/Project/KEVIN/Workspace/KenCanCode/version.h
ws-rsync upload ./version.h

Force replace local by remote

Discard every changes on local and apply remote version for local workspace

Force relplace remote by local

Discard every changes on remote and apply local version for remote workspace

Run command in remote

Run command in remote workspace

  • Example:

# ws-rsync call <command>
ws-rsync call git status
ws-rsync call ls -al