From 159484ec3edd483ffe1d085de52fee05d3a02bf8 Mon Sep 17 00:00:00 2001 From: Ossi Herrala Date: Mon, 5 May 2014 09:35:14 +0000 Subject: [PATCH] rsync backup: Add option for specifying custom rsync options. --- rsync/manifests/init.pp | 4 ++++ rsync/templates/rsync-backup.sh.erb | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rsync/manifests/init.pp b/rsync/manifests/init.pp index 45f0a8d..249a17c 100644 --- a/rsync/manifests/init.pp +++ b/rsync/manifests/init.pp @@ -117,6 +117,9 @@ class rsync::backup { # (optional) Enable rsync ACL. Defaults to enabled. Set to false # to disable. # +# $options: +# (optional) Rsync options for job. For example "--bwlimit=300". +# define rsync::backup_job ( $source_host="", $target_host="", @@ -126,6 +129,7 @@ define rsync::backup_job ( $hour, $minute=0, $enable_acl=true, + $options="", ) { include rsync diff --git a/rsync/templates/rsync-backup.sh.erb b/rsync/templates/rsync-backup.sh.erb index 8b45655..cf9bb6e 100644 --- a/rsync/templates/rsync-backup.sh.erb +++ b/rsync/templates/rsync-backup.sh.erb @@ -7,7 +7,7 @@ FLOCK_OPTS="--exclusive --nonblock" FLOCK_FILE="/var/lock/<%= @name -%>" RSYNC="/usr/bin/rsync" -RSYNC_OPTS=( -ax <%= @acl ? "-A" : "" -%> --delete --itemize-changes <%= @_excludes -%> ) +RSYNC_OPTS=( -ax <%= @acl ? "-A" : "" -%> <%= @options ? options : "" -%> --delete --itemize-changes <%= @_excludes -%> ) ( $FLOCK $FLOCK_OPTS 200 || exit $? @@ -16,7 +16,7 @@ RSYNC_OPTS=( -ax <%= @acl ? "-A" : "" -%> --delete --itemize-changes <%= @_exclu /usr/bin/time -p $RSYNC "${RSYNC_OPTS[@]}" <%= @_source -%> <%= @_target %> RSYNCEXIT=$? if [ $RSYNCEXIT -ne 0 ]; then - echo "ERROR: rsync job (<%= @name -%>) process returned $RSYNCEXIT" + echo "ERROR: rsync job (<%= @name -%>) process returned $RSYNCEXIT" fi /usr/bin/printf "\n***** Backup ended %s\n" "$(date +"%F %T UTC")" ) 200>$FLOCK_FILE >$LOGFILE 2>&1