|
@@ -0,0 +1,67 @@
|
|
|
|
|
+#!/bin/bash
|
|
|
|
|
+# info: Dumps the files of a site into a zip archive
|
|
|
|
|
+# options: USER DOMAIN [TYPE]
|
|
|
|
|
+#
|
|
|
|
|
+# example: v-dump-site user domain
|
|
|
|
|
+# example: v-dump-site user domain full
|
|
|
|
|
+#
|
|
|
|
|
+# Dumps site files in /backup/user.domain.timestamp.zip
|
|
|
|
|
+
|
|
|
|
|
+#----------------------------------------------------------#
|
|
|
|
|
+# Variables & Functions #
|
|
|
|
|
+#----------------------------------------------------------#
|
|
|
|
|
+
|
|
|
|
|
+# Argument definition
|
|
|
|
|
+user=$1
|
|
|
|
|
+domain=$2
|
|
|
|
|
+type=$3
|
|
|
|
|
+
|
|
|
|
|
+# Includes
|
|
|
|
|
+# shellcheck source=/etc/hestiacp/hestia.conf
|
|
|
|
|
+source /etc/hestiacp/hestia.conf
|
|
|
|
|
+# shellcheck source=/usr/local/hestia/func/main.sh
|
|
|
|
|
+source $HESTIA/func/main.sh
|
|
|
|
|
+# load config file
|
|
|
|
|
+source_conf "$HESTIA/conf/hestia.conf"
|
|
|
|
|
+
|
|
|
|
|
+check_args '2' "$#" 'USER DOMAIN'
|
|
|
|
|
+is_format_valid 'user' 'domain'
|
|
|
|
|
+is_object_valid 'user' 'USER' "$user"
|
|
|
|
|
+is_object_unsuspended 'user' 'USER' "$user"
|
|
|
|
|
+is_object_valid 'web' 'DOMAIN' "$domain"
|
|
|
|
|
+
|
|
|
|
|
+# Perform verification if read-only mode is enabled
|
|
|
|
|
+check_hestia_demo_mode
|
|
|
|
|
+
|
|
|
|
|
+#----------------------------------------------------------#
|
|
|
|
|
+# Action #
|
|
|
|
|
+#----------------------------------------------------------#
|
|
|
|
|
+
|
|
|
|
|
+# Create timestamp in Y-M-D_h-m-s format
|
|
|
|
|
+timestamp=$(date +'%G-%m-%d_%H-%M-%S')
|
|
|
|
|
+
|
|
|
|
|
+# echo filename for use in the php
|
|
|
|
|
+echo "$user.$domain.$timestamp.zip"
|
|
|
|
|
+
|
|
|
|
|
+if [ "$type" = "full" ]; then
|
|
|
|
|
+ cd /home/$user/web/$domain/
|
|
|
|
|
+else
|
|
|
|
|
+ cd /home/$user/web/$domain/public_html/
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+zip -rq $BACKUP/$user.$domain.$timestamp.zip .
|
|
|
|
|
+
|
|
|
|
|
+if [[ -f "$BACKUP/$user.$domain.$timestamp.zip" ]]; then
|
|
|
|
|
+ echo "$BACKUP/$user.$domain.$timestamp.zip"
|
|
|
|
|
+ echo "rm $BACKUP/$user.$domain.$timestamp.zip" | at now + 1 hour
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+#----------------------------------------------------------#
|
|
|
|
|
+# Hestia #
|
|
|
|
|
+#----------------------------------------------------------#
|
|
|
|
|
+
|
|
|
|
|
+# Logging
|
|
|
|
|
+log_event "$OK" "$ARGUMENTS"
|
|
|
|
|
+
|
|
|
|
|
+exit
|
|
|
|
|
+
|