diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2011-09-27 15:29:42 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2011-09-27 15:29:42 -0300 |
commit | c967d8a5f701d9fdfe65f8c965557632fb11a876 (patch) | |
tree | 47f05bef5a28758e8744f29e03491ee5b1265fb7 /share/hydractl | |
parent | d55569f80013310a97c33dbd2de41f76a6437ced (diff) | |
download | hydra-c967d8a5f701d9fdfe65f8c965557632fb11a876.tar.gz hydra-c967d8a5f701d9fdfe65f8c965557632fb11a876.tar.bz2 |
Coding backup-site
Diffstat (limited to 'share/hydractl')
-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" |