diff options
Diffstat (limited to 'share/hydractl/backup-restore-site')
-rwxr-xr-x | share/hydractl/backup-restore-site | 53 |
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 |