npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jdsp/jp-sync

v0.0.6

Published

Watch and rsync directories locally, remotely or in a cloud setup.

Downloads

9

Readme

Use Cases

You can perform all use cases simultaneously by including all the settings you need in one config file.

1. Sync Local to Remotes

Watch and sync directories from a local machine to remote servers. This is useful for software development that needs to sync code and other files with a remote server for live testing. It can also be used for live remote backups.

jp-sync.json

[
  {
    "watch": ["/home/user/project1", "/home/user/project2"],
    "rsync": {
      "locations": ["username1@fqdn1:/var/www", "username2@fqdn2:/var/www"]
    }
  }, {
    "watch": ["/home/user/project3"],
    "rsync": {
      "locations": ["username3@fqdn3:/home/user"]
    }
  }
]

2. Cloud Sync

Create an efficient decentralised, replicated, fault tolerant cloud that keeps data in specified directories consistent with each other on a specified set of servers.

jp-sync.json

[
  {
    "watch": ["/etc/nginx/conf.d"],
    "cloud": {
      "serversEnvVar": "SERVERS",
      "username": "root"
    },
    "postSyncCmd": "service nginx restart"
  }, {
    "watch": ["/home/user/project1"],
    "cloud": {
      "serversEnvVar": "SERVERS",
      "username": "root"
    },
    "postSyncCmd": "service project1.service restart"
  }
]

3. Live Local Backups

Backup to an external hard drive connected to your local machine.

jp-sync.json

[
  {
    "watch": ["test1"],
    "rsync": {
      "destinations": ["test2"],
    }
  }
]

Requirements

  1. fswatch must be available on your system.

  2. rsync must be installed on the local and remote machines with the relavant certificates configured so that it can sync to remote servers without asking for the password.

MacOS: $ brew install fswatch rsync

Ubuntu: $ sudo apt install fswatch rsync

Usage

  1. Install:

    $ npm install --global @jdsp/sync
  2. Create a config file, jp-sync.json, according to your use case listed above.

  3. Start watching and syncing by executing this sync in the same directory as the config file:

    $ ls
    jp-sync.json
    $ jp-sync

You can specify your own config filename on the command line if you wish e.g.:

$ ls
my.json
$ jp-sync my.json

jp-sync.json

watch

An array of local directories to watch for syncing.

rsync locations

An array of rsync locations. The syntax of these is the same as that of an rsync destination i.e. fqdn1:path.

rsync params

Include any rsync parameters you like. By default the -r option is included to recursively sync directories.

cloud serversEnvVar

Add a comma separated list of servers to an environemnt variable e.g. SERVERS. To set this edit your /etc/environment file and add the line:

SERVERS=<fqdn1>,<fqdn2>,...

cloud username

This is the username that will be used to access all servers in serversEnvVar. It is equivalent to rsync <username>@<fqdn>:<path> ....

postSyncCmd

Enter a command line command to be executed after the rsync completes e.g.: service nginx restart