]> gitweb.fluxo.info Git - hydra.git/commitdiff
Try to get the newest if there's no backup for the current date
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 11 Mar 2014 02:05:29 +0000 (23:05 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 11 Mar 2014 02:05:29 +0000 (23:05 -0300)
lib/hydra/backup

index e48f904352a18318383e73108fada6ff6da35d04..3f2d91fdfc116534320128e001c50d8b945b133a 100644 (file)
@@ -17,6 +17,16 @@ function hydra_backup_environment_local_website {
     RESTOREDIR="$BACKUPDIR/`date +%Y%m%d`"
   fi
 
+  # Try to get the newest if there's no backup for the current date
+  if [ ! -e "$RESTOREDIR/$SITE.tar.bz2" ]; then
+    RESTOREDIR="$(find $BACKUPDIR -name "$SITE.tar.bz2" | sort -n | tail -n 1)"
+
+    if [ -z "$RESTOREDIR" ]; then
+      echo "Backup not found for $DATE."
+      exit 1
+    fi
+  fi
+
   DB_DUMP_BASE="$RESTOREDIR"
   mkdir -p $RESTOREDIR  
 }