]> gitweb.fluxo.info Git - puppet-backup.git/commitdiff
Partially regressing last change and fixing metadata handling at rotate_long functions
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 20 Sep 2010 21:50:28 +0000 (18:50 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 20 Sep 2010 21:50:28 +0000 (18:50 -0300)
files/handlers/rsync

index dffcfc593492e6647fe9a048e5881b8afb466957..e55b512e40061f08f2f3a60dc5367e27d894d7be 100644 (file)
@@ -384,14 +384,14 @@ function rotate_long {
 
   for rottype in daily weekly monthly; do
     seconds=$((seconds_${rottype}))
-
     dir="$backuproot/$rottype"
-    metadata="$backuproot/metadata/$rottype.1"
-    mkdir -p $metadata
+    metadata="$backuproot/metadata/$rottype"
+
+    mkdir -p $metadata.1
     if [ ! -d $dir.1 ]; then
       echo "Debug: $dir.1 does not exist, skipping."
       continue 1
-    elif [ ! -f $metadata/created ] && [ ! -f $metadata/rotated ]; then
+    elif [ ! -f $metadata.1/created ] && [ ! -f $metadata.1/rotated ]; then
       echo "Warning: metadata does not exist for $dir.1. This backup may be only partially completed. Skipping rotation."
       continue 1
     fi
@@ -401,10 +401,10 @@ function rotate_long {
     [ "$oldest" == "" ] && oldest=0
     for (( i=$oldest; i > 0; i-- )); do
       if [ -d $dir.$i ]; then
-        if [ -f $metadata/created ]; then
-          created=`tail -1 $metadata/created`
-        elif [ -f $metadata/rotated ]; then
-          created=`tail -1 $metadata/rotated`
+        if [ -f $metadata.$i/created ]; then
+          created=`tail -1 $metadata.$i/created`
+        elif [ -f $metadata.$i/rotated ]; then
+          created=`tail -1 $metadata.$i/rotated`
         else
           created=0
         fi
@@ -414,9 +414,9 @@ function rotate_long {
           if [ ! -d $dir.$next ]; then
             echo "Debug: $rottype.$i --> $rottype.$next"
             $nice mv $dir.$i $dir.$next
-            mkdir -p $backuproot/metadata/$rottype.$next
-            date +%c%n%s > $backuproot/metadata/$rottype.$next/rotated
-            rm -f $backuproot/metadata/$rottype.$next/created
+            mkdir -p $metadata.$next
+            date +%c%n%s > $metadata.$next/rotated
+            rm -f $metadata.$next/created
           else
             echo "Debug: skipping rotation of $dir.$i because $dir.$next already exists."
           fi
@@ -486,14 +486,14 @@ function rotate_long_remote {
 
   for rottype in daily weekly monthly; do
     seconds=\$((seconds_\${rottype}))
-
     dir="$backuproot/\$rottype"
     metadata="$backuproot/metadata/\$rottype.1"
-    mkdir -p \$metadata
+
+    mkdir -p \$metadata.1
     if [ ! -d \$dir.1 ]; then
       echo "Debug: \$dir.1 does not exist, skipping."
       continue 1
-    elif [ ! -f \$metadata/created ] && [ ! -f \$metadata/rotated ]; then
+    elif [ ! -f \$metadata.1/created ] && [ ! -f \$metadata.1/rotated ]; then
       echo "Warning: metadata does not exist for \$dir.1. This backup may be only partially completed. Skipping rotation."
       continue 1
     fi
@@ -503,10 +503,10 @@ function rotate_long_remote {
     [ "\$oldest" == "" ] && oldest=0
     for (( i=\$oldest; i > 0; i-- )); do
       if [ -d \$dir.\$i ]; then
-        if [ -f \$metadata/created ]; then
-          created=\`tail -1 \$metadata/created\`
-        elif [ -f \$metadata/rotated ]; then
-          created=\`tail -1 \$metadata/rotated\`
+        if [ -f \$metadata.\$i/created ]; then
+          created=\`tail -1 \$metadata.\$i/created\`
+        elif [ -f \$metadata.\$i/rotated ]; then
+          created=\`tail -1 \$metadata.\$i/rotated\`
         else
           created=0
         fi
@@ -516,9 +516,9 @@ function rotate_long_remote {
           if [ ! -d \$dir.\$next ]; then
             echo "Debug: \$rottype.\$i --> \$rottype.\$next"
             $nice mv \$dir.\$i \$dir.\$next
-            mkdir -p $backuproot/metadata/\$rottype.\$next
-            date +%c%n%s > $backuproot/metadata/\$rottype.\$next/rotated
-            rm -f $backuproot/metadata/\$rottype.\$next/created
+            mkdir -p \$metadata.\$next
+            date +%c%n%s > \$metadata.\$next/rotated
+            rm -f \$metadata.\$next/created
           else
             echo "Debug: skipping rotation of \$dir.\$i because \$dir.\$next already exists."
           fi
@@ -583,8 +583,7 @@ function setup_long_dirs {
 
   if [ -d $dir.1 ]; then
     if [ -f $metadata/created ]; then
-      echo "Warning: $dir.1 already exists, aborting."
-      exit
+      echo "Warning: $dir.1 already exists. Overwriting contents."
     else
       echo "Warning: we seem to be resuming a partially written $dir.1"
     fi
@@ -634,8 +633,7 @@ function setup_long_dirs_remote {
 
   if [ -d $dir.1 ]; then
     if [ -f $metadata/created ]; then
-      echo "Warning: $dir.1 already exists, aborting."
-      exit
+      echo "Warning: $dir.1 already exists. Overwriting contents."
     else
       echo "Warning: we seem to be resuming a partially written $dir.1"
     fi