diff options
-rwxr-xr-x | share/hydractl/backup-restore | 2 | ||||
-rwxr-xr-x | share/hydractl/backup-restore-gitosis | 16 | ||||
-rwxr-xr-x | share/hydractl/backup-restore-site | 53 | ||||
-rwxr-xr-x | share/hydractl/backup-restore-svn | 16 | ||||
-rwxr-xr-x | share/hydractl/backup-site | 3 |
5 files changed, 88 insertions, 2 deletions
diff --git a/share/hydractl/backup-restore b/share/hydractl/backup-restore index 581ac63..acd3be4 100755 --- a/share/hydractl/backup-restore +++ b/share/hydractl/backup-restore @@ -2,6 +2,8 @@ # # Backup restoration. # +# TODO: optionally restore from local backup +# # Load. source $APP_BASE/lib/hydra/functions || exit 1 diff --git a/share/hydractl/backup-restore-gitosis b/share/hydractl/backup-restore-gitosis index e69de29..d430693 100755 --- a/share/hydractl/backup-restore-gitosis +++ b/share/hydractl/backup-restore-gitosis @@ -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 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 diff --git a/share/hydractl/backup-restore-svn b/share/hydractl/backup-restore-svn index e69de29..91c0988 100755 --- a/share/hydractl/backup-restore-svn +++ b/share/hydractl/backup-restore-svn @@ -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 diff --git a/share/hydractl/backup-site b/share/hydractl/backup-site index 2d1175b..53119da 100755 --- a/share/hydractl/backup-site +++ b/share/hydractl/backup-site @@ -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" |