Gathering detailed insights and metrics for rsyncwrapper-rabhw
Gathering detailed insights and metrics for rsyncwrapper-rabhw
npm install rsyncwrapper-rabhw
Typescript
Module System
Min. Node Version
NPM Version
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
1,347
Last Day
2
Last Week
7
Last Month
36
Last Year
155
Latest Version
0.0.1
Package Id
rsyncwrapper-rabhw@0.0.1
Size
5.09 kB
NPM Version
1.2.15
Cumulative downloads
Total Downloads
Last day
100%
2
Compared to previous day
Last week
75%
7
Compared to previous week
Last month
260%
36
Compared to previous month
Last year
82.4%
155
Compared to previous year
1
5
An async wrapper to the rsync command line utility for Node.js.
Modified to fix compatibility with our build environment.
A reasonably modern version of rsync (>=2.6.9) in your PATH.
$ npm install rsyncwrapper
1var rsync = require("rsyncwrapper").rsync; 2rsync(options,[callback]);
The callback
function gets four arguments (error,stdout,stderr,cmd)
.
error
: An Error
object if rsync failed, otherwise null
.
stdout
: stdout from rsync.
stderr
: stderr from rsync.
cmd
: The command string that was used to invoke rsync for debugging purposes.
The options
argument is an object literal with the following possible fields:
1{ 2 src: "some/path", // Required string, path to file or dir to copy. src can also be 3 // an array of strings for copying multiple files, for example: 4 // ["./dir-a/file1","./dir-b/file2"] 5 dest: "some/path", // Required string, path to copy destination. 6 host: "user@host", // Optional string, remote host to prefix to dest if copying over 7 // ssh. Needs public/private key passwordless SSH access to your 8 // host to be working on your workstation. 9 port: "1234", // If your SSH host uses a non standard SSH port then set it here. 10 recursive: true, // Optional boolean, recursively copy dirs, sub-dirs and files. Only 11 // files in the root of src are copied unless this option is true. 12 syncDest: true, // Optional boolean, delete objects in dest that aren't present 13 // in src. Take care with this option, since misconfiguration 14 // could cause data loss. Maybe dryRun first? 15 syncDestIgnoreExcl: true, // Optional boolean, delete objects in dest that aren't present 16 // in src. Ignores excluded. Useful for such folders as 17 // `node_modules`. Take care with this option, since misconfiguration 18 // could cause data loss. Maybe dryRun first? 19 compareMode: "checksum", // Optional string, adjust the way rsync determines if files need 20 // copying. By default rsync will check using file mod date and size. 21 // Set this option to "checksum" to use a 128bit checksum to check 22 // if a file has changed, or "sizeOnly" to only use a file's size. 23 exclude: ["*.txt"], // Optional array of rsync patterns to exclude from the operation. 24 dryRun: false, // Optional boolean, if true rsync will output verbose info to stdout 25 // about the actions it would take but does not modify the filesystem. 26 args: ["--verbose"] // Optional array of any additional rsync args you'd like to include. 27}
The above options are provided for convenience and are designed to cover the most common use cases for rsync, they don't necessarily map directly to single rsync arguments with the same names. If you'd like to handcraft your rsync command then just use the src
, dest
and args
options.
For extra information and subtlety relating to rsync options please consult the rsync manpages.
Basic tests are run on Vows Async BDD via this package's Gruntfile. To test rsyncwrapper clone the repo and ensure that the devDependancies are present. Additionally ensure that Grunt and Vows are installed globally, and then invoke:
$ npm test
Copy a single file to another location. If the dest
folder doesn't exist rsync will do a mkdir
and create it. However it will only mkdir
one missing directory deep (i.e. not the equivalent of mkdir -p
).
1rsync({ 2 src: "./file.txt", 3 dest: "./tmp/file.txt" 4},function (error,stdout,stderr,cmd) { 5 if ( error ) { 6 // failed 7 console.log(error.message); 8 } else { 9 // success 10 } 11});
Copy the contents of a directory to another folder, while excluding txt
files. Note the trailing /
on the src
folder and the absence of a trailing /
on the dest
folder - this is the required format when copy the contents of a folder. Again rsync will only mkdir
one level deep:
1rsync({ 2 src: "./src-folder/", 3 dest: "./dest-folder", 4 recursive: true, 5 exclude: ["*.txt"] 6},function (error,stdout,stderr,cmd) { 7 if ( error ) { 8 // failed 9 console.log(error.message); 10 } else { 11 // success 12 } 13});
Syncronise the contents of a directory on a remote host with the contents of a local directory using the checksum algorithm to determine if a file needs copying:
1rsync({ 2 src: "./local-src/", 3 dest: "/var/www/remote-dest", 4 host: "user@1.2.3.4", 5 recursive: true, 6 syncDest: true, 7 compareMode: "checksum" 8},function (error,stdout,stderr,cmd) { 9 if ( error ) { 10 // failed 11 console.log(error.message); 12 } else { 13 // success 14 } 15});
No vulnerabilities found.
No security vulnerabilities found.