Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A gruntplugin which copies files to a (remote) machine with rsync.
JavaScript Erlang
Branch: grunt-4.0
Pull request Compare This branch is 4 commits ahead, 20 commits behind master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tasks
test
.gitignore
.npmignore
Gruntfile.js
LICENSE-MIT
README.md
package.json

README.md

grunt-rsync-2

Copy files to a (remote) machine running an SSH daemon with 'rsync'.

See also: https://github.com/jedrichards/grunt-rsync

Getting Started

rsync has to be installed on the local and remote system. rsync must be able to connect to the host without password (e.g. public key authentication)

Install with: npm install grunt-rsync-2

Inside your grunt.js file add :

grunt.loadNpmTasks('grunt-rsync-2');

and a task named rsync (see Configuration)!

Configuration

Add a configuration like this:

grunt.initConfig({
  ...
  rsync: {
        deploy: {
          src: 'dist/',
          options: {
            host      : "example.com",
            port      : "1023",
            user      : "jdoe",
            remoteBase: "~/production"
          }
        }
      },
    ...
});

This will transfer the content of the dist/ directory (relative to the current directory) to the host directory ~/production (relative to the user home) on the host example.com:1023 logged in with jdoe.

:exclamation: Files on the remote machine will be overridden

File option: files

This option follows the grunt-0.4 file option specs (https://github.com/gruntjs/grunt/wiki/Configuring-tasks#files). For more dedicated description see the following examples:

Examples:

Simple file-descriptor:
rsync: {
  deploy: {
    src: 'dist/**/*.jpg' // globbing
    ...
  }  
}

selects all jpg-images from all directories in dist

Mapping single file-descriptor:
rsync: {
  deploy: {
    files: {'images/' : 'dist/**/*.jpg'} // map <String>:<String>
    options: {
      ...
      remoteBase: "~/production"
    }
  }  
}

selects all jpg-images from all directories in dist to remote ~/production/images/

Mapping multiple file-descriptor:
rsync: {
  deploy: {
    files: {'images/' : ['dist/images/*.jpg', 'dist/img/*.jpg']} // map <String>:[<String>]
    options: {
      ...
      remoteBase: "~/production"
    }
  }  
}

selects all jpg-images from images and img directories in dist to remote ~/production/images/

rsync options: options

  • host: the hostname or ip (ip4/ip6). Default: localhost
  • port: the port of the ssh server on the host. Default: 22
  • user: the user name on the remote to log in with.
  • remoteBase: the path from root (defined by the ssh server) to the directory to place the content in. Default: ~
  • preserveTimes: keeps the origin timestamp. Default: false
  • preservePermissions: keeps the rights. Default: true
  • compression: transfer with compression. Default: true
  • recursive: transfer the source directory recursivly Default: true
  • additionalOptions: rsync commandline arguments (see man rsync) Default: ''

Release History

  • 0.2.0 : grunt 0.4 support and major changes
    • multithreaded async rsync for every file entry in file map
    • fixed rsync sysout capture
  • 0.1.1 : initial release to github and npm

License

Copyright (c) 2012-2013 Jan-Philip Loos Licensed under the MIT license.

Something went wrong with that request. Please try again.