-
-
Notifications
You must be signed in to change notification settings - Fork 680
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
use function Hestiacp\quoteshellarg\quoteshellarg; | ||
|
||
ob_start(); | ||
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php"; | ||
|
||
// Check token | ||
verify_csrf($_GET); | ||
|
||
$site = quoteshellarg($_GET["site"]); | ||
|
||
exec(HESTIA_CMD . "v-dump-site " . $user . " " . $site . " full", $output, $return_var); | ||
|
||
if ($return_var == 0) { | ||
header("Content-type: application/zip"); | ||
header("Content-Disposition: attachment; filename=" . $output[0]); | ||
header("X-Accel-Redirect: " . $output[1]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters