Socket
Socket
Sign inDemoInstall

ftpsync

Package Overview
Dependencies
4
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

ftpsync


Version published
Maintainers
1
Created

Readme

Source

An FTP synchronization app for NodeJS based on jsftp. With an emphasis on speed and simplicity ftpsync aims to fulfull your one-click file deployment needs.

NPM

Warning: This app is currently in the early alpha stages of development. Feel free to try it out and contribute fixes/feedback but it would be wise to wait a few releases before using it in a production environment.

Usage

$ node ftpsync --help

 Usage: ftpsync [options]

 Options:

   -h, --help            output usage information
   -V, --version         output the version number
   -v, --verbose         Verbose logging
   -l, --local []        Local root path
   -r, --remote []       Remote root path
   -h, --host []         FTP host name/address
   -p, --port <>         FTP connection port
   -u, --user []         FTP user name
   -s, --pass []         FTP password
   -c, --connections <>  Max number of concurrent FTP connections
   -i, --ignore <items>  List of files to ignore (separated by commas)

See ftpsync.settings{} for detailed info about the settings.

Using a config file

As an alternative to the traditional command line interface a config file may also be used to load the settings.

Step 1 - Create a configuration file

config.json

{
  "local":"~/www/",
  "remote":"/",
  "host":"example.com",
  "port":21,
  "user":"username",
  "pass":"password",
  "connection":"2",
  "ignore":[
    ".htaccess"
  ]
}

See ftpsync.settings{} for detailed info about the settings.

Step 2 - Place the config file in the directory where ftpsync will be exectued

By default ftpsync will use the configuration supplied buy a config.json file located in the CWD.

Step 3 - Run the script

node ftpsync

Optional - Logging to a file

To log the output to a file simply pipe STDOUT to a log file.

npm ftpsync > ftpsync.log &

API

new ftpsync(options)

Creates a new ftpsync instance.

  • options{} an object containing settings for ftpsync.

See ftpsync.settings{} for detailed info about the settings.

ftpsync.settings{}

Contains the application settings for ftpsync.

  • host - hostname/address of the remote ftp server (required).
  • port - port of the remote ftp server (default 21).
  • user - ftp username (required).
  • pass - ftp password (required).
  • localRoot - the root directory of the local host (default './').
  • remoteRoot - the root path of the remote server (default './').
  • connections - the max number of concurrent ftp connections (default 1).
  • lTimeOffset - the local hosts timezone offset (autodetected).
  • rTimeOffset - the remoge ftp server's timezone offset (autodetected).
ftpsync.local[]

The file listing for the local host. Populated by running collect().

ftpsync.remote[]

The file listing for the remote server. Populated by running collect().

ftpsync.add[]

The list of files queued to for addition to the remote server. Populated by running consolidate().

ftpsync.update[]

The list of files queued for update on the remote server. Populated by running consolidate().

ftpsync.remove[]

The list of files queued for removal from the remote server. Populated by running consolidate().

Methods

ftpsync.run(callback)

Completes the full synchronization from start to finish. Runs setup(), collect(), consolidate(), commit(), and validate().

ftpsync.setup(callback)

The initialization step of the sunchronization process. This function accomplishes two tasks, First, it checks to see that all the required settings are present. Second, it synchronizes the local host and remote server clocks.

The setup will fail if the following settings aren't defined:

  • host
  • port
  • user
  • pass

See ftpsync.settings{} for detailed info about the settings.

ftpsync.collect(callback)

Walks the file trees for both the local host and remote server and prepares them for further processing. The resulting file lists are stored in local[], and remote[] upon successful completion.

ftpsync.consolidate(callback)

Runs comparisons on the local and remote file listings. Files that exist in the local directory are but not the remote are queued up for addition. Files that exist in both but are different (determined by file size and time stamp) are queued for update. Files that exist in on the remote directory but not the local are queued for removal. The resulting queues can be found in add[], update[], and remove[] upon successful completion.

ftpsync.commit(callback)

Executes the tasks contained in the add[], update[], and remove[] lists.

Helper Methods

ftpsync.utils.walkLocal(dir, callback)

Walks the local directory tree and returns a list of files.

Requires setup() to be run first.

ftpsync.utils.walkRemote(dir, callback)

Walks the remote directory tree and returns a list of files.

Requires setup() to be run first.

Installation

npm install -g ftpsync

The -g flag indicates that this package will be installed globally. If you'd like to install it directly to a file locally simply remove the flag.

License

See LICENSE.

Keywords

FAQs

Last updated on 04 Dec 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc