Installations
npm install rsyncwrapper
Developer Guide
Typescript
Yes
Module System
CommonJS
Min. Node Version
>=8.1.3
Node Version
18.12.1
NPM Version
8.19.2
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
jedrichards
Download Statistics
Total Downloads
1,769,619
Last Day
1,158
Last Week
2,618
Last Month
21,561
Last Year
270,855
GitHub Statistics
125 Stars
157 Commits
44 Forks
5 Watching
1 Branches
20 Contributors
Bundle Size
2.45 kB
Minified
1.10 kB
Minified + Gzipped
Package Meta Information
Latest Version
3.1.0
Package Id
rsyncwrapper@3.1.0
Unpacked Size
26.56 kB
Size
7.59 kB
File Count
13
NPM Version
8.19.2
Node Version
18.12.1
Publised On
26 Sept 2024
Total Downloads
Cumulative downloads
Total Downloads
1,769,619
Last day
5.7%
1,158
Compared to previous day
Last week
-49.9%
2,618
Compared to previous week
Last month
-1.5%
21,561
Compared to previous month
Last year
114.4%
270,855
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
rsyncwrapper
An async wrapper to the rsync command line utility for Node.js. Also available as the Grunt task grunt-rsync.
Release notes
3.1.0
- Replace deprecated Node util functions
- Add error code to the error object
3.0.1
- Add TypeScript types
3.0.0
- Node LTS Carbon
v8.11.3
now minimum Node version - Remove lodash dependency
- Port tests to Jest
- Node LTS Carbon
2.0.1
Upgrade to modern lodash~4.15.0
2.0.0
Escape non-escaped spaces in argument paths #471.0.1
Improved error handling in #45. Added atimes
option for preserving modification times in #44.1.0.0
Bumped to version 1! Package now considered stable :tada: With this comes a minor API change, the module no longer exports an object with anrsync
function. Rather thersync
function is exported as the main value of the module. Check the usage section for an example.0.5.1
Added thesshCmdArgs
option to enable additional customisation of the rsh ssh subcommand. See #37 and #38. Made the tests pass on modern versions of Node, see #36 - this package is now tested to work on all versions of Node from0.10.25
to5.3.0
.0.4.3
Added theexcludeFirst
option. See #34.0.4.2
Add defaultchmod
arguments on Windows to fix NTFS permissions, see #28.0.4.1
RenamedsyncDest
andsyncDestIgnoreExcl
options to the more scary soundingdeleteAll
anddelete
options in an effort to avoid potential user data loss due to misconfiguration. Updated docs to use the new option names. The old option names will continue to work.0.4.0
Reworking the way stdin is passed from the process to the rsync child process to facilitate Windows clients being able to read a passphrase from stdin.0.3.0
Swapping include/exclude order in the generated rsync command. Includes now come before excludes to faciliate the normal way of excluding file patterns with exceptions in rsync. See #16.0.2.0
Now launching the rsync command in a shell likechild_process.exec
does in Node Core. This enables us to usespawn
, and avoidexec
maxBuffer
, while retaining full shell wildcard expansion.0.1.0
Now usingchild_process.exec
as opposed tochild_process.spawn
to enable proper shell wildcard expansions in theoptions.src
value. SSH option handling has been improved.0.0.1
Initial release.
Prerequisites
A reasonably modern version of rsync (>=2.6.9) in your PATH.
Installation
$ npm install rsyncwrapper
Usage
1var rsync = require('rsyncwrapper') 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. See below for possible fields.
Options
src [String|Array<String>] *required
Path to src. Can be a single filename, or an array of filenames. Shell wildcard expansion is supported. Examples:
src: "./dist/"
src: ["./dir-a/file1","./dir-b/file2"]
src: "./*.foo"
src: "foo{1,2,3}.txt"
etc.
dest [String] *required
Path to destination. Example, "/var/www/mysite.tld"
.
ssh [Bool] default: false
Run rsync over ssh. This is false
by default. To use this you need to have public/private key passwordless ssh access setup and working between your workstation and your host. If set to true
, you should specify ssh host data as part of your src
or dest
values, e.g. user@1.2.3.4:/var/www/site
.
Another good approach is to define a host alias in your ssh config and just reference that alias in your rsync options.
port [String]
If your ssh host uses a non standard SSH port then set it here. Example, "1234"
.
privateKey [String]
To specify an SSH private key other than the default for this host. Example, "~/.ssh/aws.pem"
sshCmdArgs [Array]
Add an array of arbitrary additional args to the rsh ssh subcommand. This can be useful for turning off strict host key checking to avoid typing yes
or no
when connecting to new hosts. See SSH's clients man page for more. Example, ["-o StrictHostKeyChecking=no"]
recursive [Boolean] default: false
Recurse into directories. This is false
by default which means only files in the src
root are copied. Equivalent to the --recursive
rsync command line flag.
:exclamation: deleteAll [Boolean] default: false
Take care with this option, since misconfiguration could cause data loss. Deletes objects in dest
that aren't present in src
, also deletes files in dest
that have been specifically excluded from transfer. Equivalent to setting both the --delete
and --delete-excluded
rsync flags.
:exclamation: delete [Boolean] default: false
Take care with this option, since misconfiguration could cause data loss. The same as deleteAll
, but without the --delete-excluded
behaviour. One use case for using this option could be while syncing a Node app to a server: you want to exclude transferring the local node_modules
folder while retaining the remote node_modules
folder.
compareMode [String] enum: "checksum"|"sizeOnly"
By default files will be compared by modified date and file size. Set this value to checksum
to compare by a 128bit checksum, or sizeOnly
to compare only by file size.
include [Array<String>]
Optional array of rsync patterns to include in the transfer, if previously excluded. Include patterns are defined before exclude patterns when building the rsync command.
exclude [Array<String>]
Optional array of rsync patterns to exclude from transfer. Include patterns are defined before exclude patterns when building the rsync command.
excludeFirst [Array<String>]
Optional array of rsync patterns to exclude from transfer. These are defined before the include patterns when building the rsync command. This is useful to exclude specific files or folders that would be included by the include patterns.
dryRun [Boolean] default: false
Buffer verbose information to stdout about the actions rsyncwrapper would take without modifying the filesystem. Equivalent to setting both the --dry-run
and --verbose
rsync command line flags.
onStdout [Function]
Optional callback function. Called every time rsync outputs to stdout
. Use this to print rsync output as it happens, rather than all at the end. Example: function (data) { console.log(data) }
.
onStderr [Function]
Optional callback function. Called every time rsync outputs to stderr
. Use this to print rsync error output as it happens, rather than all at the end. Example: function (data) { console.log(data) }
.
times [Boolean]
Uses the rsync --times
flag to transfer modification times along with the files and update them on the remote system.
args [Array<String>]
Array of additional arbitrary rsync command line options and flags.
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.
Tests
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
Examples
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 { 3 src: 'file.txt', 4 dest: 'tmp/file.txt', 5 }, 6 function (error, stdout, stderr, cmd) { 7 if (error) { 8 // failed 9 console.log(error.message) 10 } else { 11 // success 12 } 13 } 14)
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 copying the contents of a folder. Again rsync will only mkdir
one level deep:
1rsync( 2 { 3 src: 'src-folder/', 4 dest: 'dest-folder', 5 recursive: true, 6 exclude: ['*.txt'], 7 }, 8 function (error, stdout, stderr, cmd) { 9 if (error) { 10 // failed 11 console.log(error.message) 12 } else { 13 // success 14 } 15 } 16)
Synchronize the contents of a directory on a remote host with the contents of a local directory. The deleteAll
option will delete all files on the remote host that either aren't present in the local folder or have been excluded from transfer.
1rsync( 2 { 3 src: 'local-src/', 4 dest: 'user@1.2.3.4:/var/www/remote-dest', 5 ssh: true, 6 recursive: true, 7 deleteAll: true, // Careful, this could cause data loss 8 }, 9 function (error, stdout, stderr, cmd) { 10 if (error) { 11 // failed 12 console.log(error.message) 13 } else { 14 // success 15 } 16 } 17)
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 6/23 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 14 are checked with a SAST tool
Reason
66 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx
- Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-c6rq-rjc2-86v2
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm
- Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3
- Warn: Project is vulnerable to: MAL-2023-462
- Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97
- Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6
- Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9
- Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f
- Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p
- Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv
- Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8
- Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65
- Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546
- Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574
- Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm
- Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3
- Warn: Project is vulnerable to: GHSA-f9cm-qmx5-m98h
- Warn: Project is vulnerable to: GHSA-7wpw-2hjm-89gp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp
- Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
2
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to rsyncwrapper
rsyncwrapper-rabhw
An async wrapper to the rsync command line utility for Node.js.
@alumna/reflect
Reflect the contents of one directory to another. At the speed of light.
grunt-rsync
A Grunt task for accessing the file copying and syncing capabilities of the rsync command line utility. Uses the rsyncwrapper npm module for the core functionality.
grunt-rsync-rabhw
A Grunt task for accessing the file copying and syncing capabilities of the rsync command line utility. Uses the rsyncwrapper npm module for the core functionality.