]> gitweb.fluxo.info Git - hydra.git/commitdiff
Coding backup-site
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 27 Sep 2011 18:29:42 +0000 (15:29 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 27 Sep 2011 18:29:42 +0000 (15:29 -0300)
share/hydractl/backup-restore
share/hydractl/backup-restore-gitosis
share/hydractl/backup-restore-site
share/hydractl/backup-restore-svn
share/hydractl/backup-site

index 581ac6368479639b35c26ae08fa106854e9c8fdf..acd3be4b6228a68121eea5eb017bcf4c6336d2be 100755 (executable)
@@ -2,6 +2,8 @@
 #
 # Backup restoration.
 #
+# TODO: optionally restore from local backup
+#
 
 # Load.
 source $APP_BASE/lib/hydra/functions || exit 1
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d430693ca2e371cc3987c575fcee6e5515de85a5 100755 (executable)
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# Gitosis backup restoration.
+#
+# TODO
+
+# Load.
+source $APP_BASE/lib/hydra/functions || exit 1
+hydra_config_load
+
+hydra_backup_environment $*
+
+# Check if folder exist on the backup
+# Check if there's already a site folder and backup it
+# Copy site folder from backup
+# Fix permissions
index 493fc3000bc0738f640d2617ff5700f138b5bba8..970961802671124f737a92bb43008a26a2f85538 100755 (executable)
@@ -2,12 +2,15 @@
 #
 # Restore a website from backup
 #
+# TODO: moin, ikiwiki, etc
 
 # Load.
 source $APP_BASE/lib/hydra/functions || exit 1
 hydra_config_load
 
 SITE="$3"
+SITES="/var/sites"
+FOLDER="$SITES/$SITE"
 
 if [ -z "$SITE" ]; then
   hydra_action_usage
@@ -16,7 +19,53 @@ fi
 
 hydra_backup_environment $*
 
+# Check if folder exist on the backup
+if [ ! -d "$RESTOREDIR/$FOLDER" ]; then
+  echo "Folder $FOLDER does not exist at restored backup $RESTOREDIR"
+  exit 1
+fi
+
 # Check if there's already a site folder and backup it
-# Check installed platforms: trac, drupal, pmwiki
-# Drupal: check symlinks
+if [ -e "$FOLDER" ]; then
+  echo "Folder $FOLDER already exists, backing it up first..."
+  hydractl backup-site $SITE
+  if [ "$?" != "0" ]; then
+    echo "Error backing up $FOLDER"
+    exit 1
+  else
+    echo "Erasing old site folder"
+    rm -rf $FOLDER
+  fi
+fi
+
+# Copy site folder from backup
+echo "Copying site $SITE from backup $RESTOREDIR..."
+cp -a $RESTOREDIR/$FOLDER $FOLDER
+
 # Fix permissions
+chown -R root.root $FOLDER
+
+# Trac
+if [ -e "$FOLDER/trac" ]; then
+  ( cd $FOLDER/trac && chown -R $SITE.$SITE attachments conf db auth plugins .egg-cache )
+fi
+
+# PmWiki
+if [ -e "$FOLDER/wiki" ]; then
+  ( cd $FOLDER/wiki && chown -R $SITE.$SITE wiki.d uploads )
+  chown $SITE.root $FOLDER/wiki/local/config.php
+  chmod 660 $FOLDER/wiki/local/config.php
+fi
+
+# Site
+if [ -e "$FOLDER/site" ]; then
+  chown -R $SITE.$SITE $FOLDER/site
+fi
+
+# Drupal
+if [ -e "$FOLDER/drupal" ]; then
+  # TODO: how to check drupal series?
+  # TODO: check symlinks
+  chown root.$SITE $FOLDER/drupal/settings.php
+  chmod 640 $FOLDER/drupal/settings.php
+fi
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..91c098826aaee22f4622e739ea0397981d4162ab 100755 (executable)
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# Subversion backup restoration.
+#
+# TODO
+
+# Load.
+source $APP_BASE/lib/hydra/functions || exit 1
+hydra_config_load
+
+hydra_backup_environment $*
+
+# Check if folder exist on the backup
+# Check if there's already a site folder and backup it
+# Copy site folder from backup
+# Fix permissions
index 2d1175b115f4c592a6f3bc58bc91017a8c119a1e..53119da864cf2165c38b8ff7823e68a218a3985e 100755 (executable)
@@ -4,7 +4,10 @@
 #
 # TODO: put on $SITES/backups/site/$SITE, with htaccess and correct
 #       ownership/permission.
+#
 # TODO: optionally backup database before packing
+#
+# TODO: add backup files in a dated folder
 
 # Arguments
 SITES="/var/sites"