summaryrefslogtreecommitdiff
path: root/share/hydractl/backup-restore-site
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-09-27 15:29:42 -0300
committerSilvio Rhatto <rhatto@riseup.net>2011-09-27 15:29:42 -0300
commitc967d8a5f701d9fdfe65f8c965557632fb11a876 (patch)
tree47f05bef5a28758e8744f29e03491ee5b1265fb7 /share/hydractl/backup-restore-site
parentd55569f80013310a97c33dbd2de41f76a6437ced (diff)
downloadhydra-c967d8a5f701d9fdfe65f8c965557632fb11a876.tar.gz
hydra-c967d8a5f701d9fdfe65f8c965557632fb11a876.tar.bz2
Coding backup-site
Diffstat (limited to 'share/hydractl/backup-restore-site')
-rwxr-xr-xshare/hydractl/backup-restore-site53
1 files changed, 51 insertions, 2 deletions
diff --git a/share/hydractl/backup-restore-site b/share/hydractl/backup-restore-site
index 493fc30..9709618 100755
--- a/share/hydractl/backup-restore-site
+++ b/share/hydractl/backup-restore-site
@@ -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