Rsync Plugin

Use the rsync plugin to deploy files to a server using rsync over ssh. The following parameters are used to configure this plugin:

  • user - connects as this user
  • host - connects to this host address
  • port - connects to this host port
  • source - source path from which files are copied
  • target - target path to which files are copied
  • delete - delete extraneous files from the target dir
  • recursive - recursively transfer all files
  • include - include files matching the specified pattern
  • exclude - exclude files matching the specified pattern
  • filter - include or exclude files according to filtering rules
  • commands - execute commands on the remote host after files are copied

Sample configuration in the .drone.yml file:

deploy:
  rsync:
    user: root
    host: 127.0.0.1
    port: 22
    source: copy/files/from
    target: send/files/to
    delete: false
    recursive: true
    exclude:
      - "exclude/this/pattern/*"
      - "or/this/one"
    commands:
      - service nginx restart

Keys

The plugin authenticates to your server using a per-repository SSH key generated by Drone. You can find the public key in your repository settings in Drone. You will need to copy / paste this key into your ~/.ssh/authorized_keys file on your remote machine.

Common Problems

The below error message may be encountered when rsync is unable to connect to your server. First verify you can connect to your remote server via ssh. Next, make sure you have added the Drone public key to your server’s ~/.ssh/authorized_keys file as described in the previous section.

rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]
This website is a public GitHub repository, which is forked from upstream Drone CI documentation. Please help us by forking and improving upstream Drone CI documentation or Tea CI documentation.