]> gitweb.fluxo.info Git - puppet-backup.git/commitdiff
Updating rsync handler
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 1 Jun 2011 02:40:15 +0000 (23:40 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 1 Jun 2011 02:40:15 +0000 (23:40 -0300)
files/handlers/rsync

index 3d5f22f7df19663a92a91ec19905d0e500440409..9da6d92174a7cdf5f43b06cbee1d9b7b5ecf5c25 100644 (file)
@@ -35,7 +35,7 @@
 #   mountpoint = backup partition mountpoint or backup main folder (either local or remote)
 #   backupdir = folder relative do $mountpoint where the backup should be stored (local or remote)
 #   format = specify backup storage format: short, long or mirror (i.e, no rotations)
-#   days = for short storage format, specify the number of backup increments (min = 5)
+#   days = for short storage format, specify the number of backup increments (min = 2, set to 1 or less to disable)
 #   keepdaily = for long storage format, specify the number of daily backup increments
 #   keepweekly = for long storage format, specify the number of weekly backup increments
 #   keepmonthly = for long storage format, specify the number of monthly backup increments
@@ -60,7 +60,7 @@
 #   exclude_vserver = vserver-name (valid only if vservers = yes on backupninja.conf)
 #   numericids = when set to 1, use numeric ids instead of user/group mappings on rsync
 #   compress = if set to 1, compress data on rsync (remote source only)
-#   bandwidthlimit = set a badnwidth limit in kbps (remote source only)
+#   bandwidthlimit = set a badnwidth limit in KB/s (remote source only)
 #   remote_rsync = remote rsync program (remote source only)
 #   id_file = ssh key file (remote source only)
 #   batch = set to "yes" to rsync use a batch file as source
@@ -79,7 +79,7 @@
 #   port = remote port number (remote destination only)
 #   user = remote user name (remote destination only)
 #   id_file = ssh key file (remote destination only)
-#   bandwidthlimit = set a badnwidth limit in kbps (remote destination only)
+#   bandwidthlimit = set a badnwidth limit in KB/s (remote destination only)
 #   remote_rsync = remote rsync program (remote dest only)
 #   batch = set to "yes" to rsync write a batch file from the changes
 #   batchbase = folder where the batch file should be written
@@ -253,7 +253,7 @@ function eval_config {
     if [ -z "$days" ]; then
       keep="4"
     else
-      keep="`echo $days - 1 | bc -l`"
+      keep=$[$days - 1]
     fi
   fi
 
@@ -284,6 +284,9 @@ function eval_config {
     excludes="$excludes --exclude=$path"
   done
 
+  # Make sure we'll run bash at the destination
+  ssh_cmd="$ssh_cmd /bin/bash"
+
 }
 
 function rotate_short {
@@ -293,18 +296,18 @@ function rotate_short {
   local keep="$2"
   local metadata="`dirname $folder`/metadata"
 
-  if [[ "$keep" -lt 4 ]]; then
-    error "Rotate: minimum of 4 rotations"
-    exit 1
+  # No rotations
+  if [[ "$keep" -lt 1 ]]; then
+     return
   fi
 
   if [ -d $folder.$keep ]; then
     $nice $mv /$folder.$keep /$folder.tmp
   fi
 
-  for ((n=`echo "$keep - 1" | bc`; n >= 0; n--)); do
+  for ((n=$[$keep - 1]; n >= 0; n--)); do
     if [ -d $folder.$n ]; then
-      dest=`echo "$n + 1" | bc`
+      dest=$[$n + 1]
       $nice $mv /$folder.$n /$folder.$dest
       $touch /$folder.$dest
       mkdir -p $metadata/`basename $folder`.$dest
@@ -328,9 +331,9 @@ function rotate_short_remote {
   local metadata="`dirname $folder`/metadata"
   local keep="$2"
 
-  if [[ "$2" -lt 4 ]]; then
-    error "Rotate: minimum of 4 rotations"
-    exit 1
+  # No rotations
+  if [[ "$keep" -lt 1 ]]; then
+     return
   fi
 
 (
@@ -911,7 +914,7 @@ function set_rsync_options {
 
   if [ "$from" == "local" ] || [ "$dest" == "local" ]; then
     # rsync options for local sources or destinations
-    rsync_options="$rsync_options"
+    rsync_options=($rsync_options)
   fi
 
   if [ "$from" == "remote" ] || [ "$dest" == "remote" ]; then