aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xshare/hydractl/backup-restore-hidden53
1 files changed, 15 insertions, 38 deletions
diff --git a/share/hydractl/backup-restore-hidden b/share/hydractl/backup-restore-hidden
index 4e2ba2a..d439b29 100755
--- a/share/hydractl/backup-restore-hidden
+++ b/share/hydractl/backup-restore-hidden
@@ -22,59 +22,36 @@ hydra_config_load
# Parameters.
DATE="`date +%Y%m%d`"
-HIDDEN_DIR="/var/lib/tor/hidden"
+HOST="$1"
+SERVICE="hidden"
+SERVICE_DIR="/var/lib/tor/hidden"
+SERVICE_USER="debian-tor"
+SERVICE_GROUP="debian-tor"
-# Check restore strategy.
-if [ "$1" == "localhost" ] || [ "$1" == "`facter hostname`" ]; then
- hydra_backup_environment_local
-else
- hydra_backup_environment_remote $1 restore
-fi
-
-# Check if folder exist on the backup.
-if [ ! -d "$RESTOREDIR/$HIDDEN_DIR" ]; then
- echo "Hidden services folder does not exist: $RESTOREDIR/$HIDDEN_DIR"
- exit 1
-fi
-
-# Set git user.
-if hydra_check_user debian-tor; then
- HIDDEN_USER="debian-tor"
-else
- HIDDEN_USER="root"
-fi
-
-# Set git group.
-if hydra_check_group debian-tor; then
- HIDDEN_GROUP="debian-tor"
-else
- HIDDEN_GROUP="root"
-fi
-
-# TODO: Backup it?
-#hydractl backup-hidden
+# Set restore environment.
+hydra_backup_environment_service
# Restore hidden service folder from backup.
#
# Symlink creation on site instances like drupal should be done
# already by backup-restore-site.
-for folder in `ls $RESTOREDIR/$HIDDEN_DIR`; do
- if [ -e "$HIDDEN_DIR/$folder/hostname" ]; then
+for folder in `ls $RESTOREDIR/$SERVICE_DIR`; do
+ if [ -e "$SERVICE_DIR/$folder/hostname" ]; then
# A hidden service already exists
- if ! diff "$HIDDEN_DIR/$folder/hostname" "$RESTOREDIR/$HIDDEN_DIR/$folder/hostname" &> /dev/null; then
+ if ! diff "$SERVICE_DIR/$folder/hostname" "$RESTOREDIR/$SERVICE_DIR/$folder/hostname" &> /dev/null; then
# They're different hidden services!
- echo "Hidden service $hidden already exists on $HIDDEN_DIR/$folder and differs from backup!"
+ echo "Hidden service $hidden already exists on $SERVICE_DIR/$folder and differs from backup!"
echo "Please fix this conflict manually and restore backups again."
else
echo "Hidden service $hidden already in place, no need to copy."
fi
else
- echo "Processing $HIDDEN_DIR/$folder..."
- rm -rf $HIDDEN_DIR/$folder
- cp -a $RESTOREDIR/$HIDDEN_DIR/$folder $HIDDEN_DIR/$folder
+ echo "Processing $SERVICE_DIR/$folder..."
+ rm -rf $SERVICE_DIR/$folder
+ cp -a $RESTOREDIR/$SERVICE_DIR/$folder $SERVICE_DIR/$folder
fi
done
# Fix permissions.
-chown -R $HIDDEN_USER.$HIDDEN_GROUP $HIDDEN_DIR
+chown -R $SERVICE_USER.$SERVICE_GROUP $SERVICE_DIR