Rex::Commands::Rsync(3pm)

Rex::Commands::Rsync3pm

Simple rsync frontend

Usage

 use Rex::Commands::Rsync;
 sync "dir1", "dir2";

Overview

With this module you can sync 2 directories via the rsync command.

Version <= 1.0: All these functions will not be reported.

All these functions are not idempotent.

Dependencies

Expect

The Expect Perl module is required to be installed on the machine executing the rsync task.

rsync

The rsync command has to be installed on both machines involved in the execution of the rsync task.

Exported functions

sync($source, $dest, $opts)

This function executes the rsync command on the local machine (where rex is being run) to sync $source and $dest with a remote. The "rsync" command is invoked with the "--recursive --links --verbose --stats" options set.

If you want to use sudo, you need to disable requiretty option for this user. You can do this with the following snippet in your sudoers configuration.

 Defaults:username !requiretty
UPLOAD - Will upload all from the local directory html to the remote directory /var/www/html.
 task "sync", "server01", sub {
   sync "html/*", "/var/www/html", {
    exclude => "*.sw*",
    parameters => '--backup --delete',
   };
 };
 task "sync", "server01", sub {
   sync "html/*", "/var/www/html", {
    exclude => ["*.sw*", "*.tmp"],
    parameters => '--backup --delete',
   };
 };
DOWNLOAD - Will download all from the remote directory /var/www/html to the local directory html.
 task "sync", "server01", sub {
   sync "/var/www/html/*", "html/", {
    download => 1,
    parameters => '--backup',
   };
 };

Releases

5 releases since Debian 9 (Stretch); the text changed 4 times.

  1. 9
  2. 10
  3. 11
  4. 12
  5. 13

From rex 1.16.0-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.