From a58fa1d4a75b8a3263e8d039106c47d9c8452a70 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 28 Jun 2012 12:54:31 -0300 Subject: Unifying service restoration with hydra_backup_environment_service --- lib/hydra/backup | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'lib/hydra/backup') diff --git a/lib/hydra/backup b/lib/hydra/backup index 0209570..9ac6833 100644 --- a/lib/hydra/backup +++ b/lib/hydra/backup @@ -88,6 +88,39 @@ function hydra_backup_environment_remote { mkdir -p $RESTOREDIR } +# Setup environment for the backups for a service +function hydra_backup_environment_service { + # Check restore strategy. + if [ "$HOST" == "localhost" ] || [ "$HOST" == "`facter hostname`" ]; then + hydra_backup_environment_local + else + hydra_backup_environment_remote $HOST restore + fi + + # Check if folder exist on the backup. + if [ ! -d "$RESTOREDIR/$SERVICE_DIR" ]; then + echo "Service folder does not exist: $RESTOREDIR/$SERVICE_DIR" + exit 1 + fi + + # Set user. + if hydra_check_user $SERVICE_USER; then + SERVICE_USER="$SERVICE_USER" + else + SERVICE_USER="root" + fi + + # Set group. + if hydra_check_group $SERVICE_GROUP; then + SERVICE_GROUP="$SERVICE_GROUP" + else + SERVICE_GROUP="root" + fi + + # TODO: Backup it? + #hydractl backup-$SERVICE +} + # Restore a database function hydra_backup_restore_database { DATABASE="$1" -- cgit v1.2.3