rsync backup: Add option for specifying custom rsync options.

This commit is contained in:
Ossi Herrala 2014-05-05 09:35:14 +00:00
parent bb0bd73076
commit 159484ec3e
2 changed files with 6 additions and 2 deletions

View file

@ -117,6 +117,9 @@ class rsync::backup {
# (optional) Enable rsync ACL. Defaults to enabled. Set to false # (optional) Enable rsync ACL. Defaults to enabled. Set to false
# to disable. # to disable.
# #
# $options:
# (optional) Rsync options for job. For example "--bwlimit=300".
#
define rsync::backup_job ( define rsync::backup_job (
$source_host="", $source_host="",
$target_host="", $target_host="",
@ -126,6 +129,7 @@ define rsync::backup_job (
$hour, $hour,
$minute=0, $minute=0,
$enable_acl=true, $enable_acl=true,
$options="",
) { ) {
include rsync include rsync

View file

@ -7,7 +7,7 @@ FLOCK_OPTS="--exclusive --nonblock"
FLOCK_FILE="/var/lock/<%= @name -%>" FLOCK_FILE="/var/lock/<%= @name -%>"
RSYNC="/usr/bin/rsync" 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 $? $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 %> /usr/bin/time -p $RSYNC "${RSYNC_OPTS[@]}" <%= @_source -%> <%= @_target %>
RSYNCEXIT=$? RSYNCEXIT=$?
if [ $RSYNCEXIT -ne 0 ]; then if [ $RSYNCEXIT -ne 0 ]; then
echo "ERROR: rsync job (<%= @name -%>) process returned $RSYNCEXIT" echo "ERROR: rsync job (<%= @name -%>) process returned $RSYNCEXIT"
fi fi
/usr/bin/printf "\n***** Backup ended %s\n" "$(date +"%F %T UTC")" /usr/bin/printf "\n***** Backup ended %s\n" "$(date +"%F %T UTC")"
) 200>$FLOCK_FILE >$LOGFILE 2>&1 ) 200>$FLOCK_FILE >$LOGFILE 2>&1