Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including pi-sync with all npm packages installed. Try it out:

var piSync = require("pi-sync")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

pi-sync v0.2.3

Auto sync codes to Raspberry Pi by SFTP, inspirated by docker-sync.


npm version Build Status Coverage Status
Auto sync codes to Raspberry Pi by SFTP, inspirated by docker-sync.


npm i -g pi-sync
# OR
npm i -D pi-sync

Node versions

node.js version 6+ needed.


Use Options

__NOTE__: Priority Level: options > pi-sync.conf.yml > Default Setting
__IMPORTANT__: An already-known bug occurs when try to sync a large project for first time, Plz use -s options when sync failed.

  Usage: pi-sync [options]


    -V, --version            output the version number
    -w, --watch              Watch files change and sync
    -H, --host <host>        SSH host name of remote device
    -p, --port <port>        SSH port number of remote device
    -a, --account <account>  SSH account name of remote device
    -P, --pass <pass>        SSH password of remote device
    -k, --key <key>          Path to SSH private key
    -r, --remote <remote>    Remote path, must be absolute path
    -s, --safe               Use safe mode, if failed first time, try safe mode
    -h, --help               output usage information


    $ pi-sync --help
    $ pi-sync -H pi@ -k PATH/TO/KEY
    $ pi-sync -H pi@ -P raspberry
    $ pi-sync -H -p 22 -a pi -P raspberry
    $ pi-sync -w -H pi@ -P raspberry
    $ pi-sync -w -H # use pi@HOSTNAME:22, pw: raspberry by default
    $ pi-sync -s -H -r /home/pi/Documents/PROJECT

Use Config File

Set pi-sync.conf.yml under repository root before use it. and run commands below.

Demo pi-sync.conf.yml

# NOTE: This sample configs could not used directly

connection: # connection setting of ssh/sftp 
  host: 192.168.x.xx # optional, default pi
  port: 22 # optional, default 22
  username: pi # needed
  password: raspberry # optional, but one of password or privateKey is needed
  # privateKey: PATH/TO/KEY # optional, but one of password or privateKey is needed
  readyTimeout: 10000 # optional, How long (in milliseconds) to wait for the SSH handshake to complete 

transport: # directory setting of sftp
  remotePath: ~/pi-sync # optional, default is ~/SAME-DIR-NAME
  localPath: ~/my-git/pi-sync # optional, default is current path
  execBefore: 'npm install' # optional, command run before transport
  execAfter: 'npm run build' # optional, command run after transport
  polling: 1500 # optional, defalt 1500ms, on --watch mode, stock changes and transport every few moment
  safeMode: false # optional, defalt false, if true, transport file one by one, slow but safe

ignore: # optional, additional ignore files which not in .gitignore

include: # optional, additional include files which ignored by .gitignore


# Batch sync
$(npm bin)/pi-sync

# Watch file changes and sync
$(npm bin)/pi-sync -w

Demo Images

Use options

Sync local pi-sync to /home/pi/Documents/pi-sync at pi@ once in safeMode. Sample Usage

Use config file and watch change

Sync local pi-sync by pi-sync.conf.yml and watch local file changes. Sample Usage

License (MIT)

Copyright 2017~2018 Jerry Lee


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free