Skip to content

Commit 474653d

Browse files
authored
[v-dump-*] Filename readability improvement / Add timestamp to v-dump-database (hestiacp#3817)
* [v-dump-site] Filename readability improvement * [v-dump-database] Filename readability improvement / Add timestamp
1 parent efcfca9 commit 474653d

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

bin/v-dump-database

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ check_hestia_demo_mode
3939
# Action #
4040
#----------------------------------------------------------#
4141

42+
# Create timestamp in Y-M-D_h-m-s format
43+
timestamp=$(date +'%G-%m-%d_%H-%M-%S')
44+
4245
# Check db existence
4346
db_data=$(grep "DB='$database'" $HESTIA/data/users/$user/db.conf)
4447
if [ -z "$db_data" ]; then
@@ -61,10 +64,16 @@ case $TYPE in
6164
esac
6265

6366
if [ "$output" = "file" ]; then
64-
cp $dump $BACKUP/$user.$database.$TYPE.sql
65-
echo $BACKUP/$user.$database.$TYPE.sql
67+
# echo filename for use in the php
68+
echo "${user}_${database}_${TYPE}_${timestamp}.sql"
69+
70+
cp $dump $BACKUP/${user}_${database}_${TYPE}_${timestamp}.sql
71+
72+
# echo file location for use in the php
73+
echo "$BACKUP/${user}_${database}_${TYPE}_${timestamp}.sql"
6674

67-
echo "rm $BACKUP/$user.$database.$TYPE.sql" | at now + 1 hour
75+
# cleanup
76+
echo "rm $BACKUP/${user}_${database}_${TYPE}_${timestamp}.sql" | at now + 1 hour
6877
else
6978
cat $dump
7079
fi

bin/v-dump-site

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,23 @@ check_hestia_demo_mode
4040
# Create timestamp in Y-M-D_h-m-s format
4141
timestamp=$(date +'%G-%m-%d_%H-%M-%S')
4242

43-
# echo filename for use in the php
44-
echo "$user.$domain.$timestamp.zip"
45-
4643
if [ "$type" = "full" ]; then
4744
cd /home/$user/web/$domain/
4845
else
4946
cd /home/$user/web/$domain/public_html/
5047
fi
5148

52-
zip -rq $BACKUP/$user.$domain.$timestamp.zip .
49+
zip -rq $BACKUP/${user}_${domain}_${timestamp}.zip .
50+
51+
if [[ -f "$BACKUP/${user}_${domain}_${timestamp}.zip" ]]; then
52+
# echo filename for use in the php
53+
echo "${user}_${domain}_${timestamp}.zip"
54+
55+
# echo file location for use in the php
56+
echo "$BACKUP/${user}_${domain}_${timestamp}.zip"
5357

54-
if [[ -f "$BACKUP/$user.$domain.$timestamp.zip" ]]; then
55-
echo "$BACKUP/$user.$domain.$timestamp.zip"
56-
echo "rm $BACKUP/$user.$domain.$timestamp.zip" | at now + 1 hour
58+
# cleanup
59+
echo "rm $BACKUP/${user}_${domain}_${timestamp}.zip" | at now + 1 hour
5760
fi
5861

5962
#----------------------------------------------------------#

web/download/database/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313

1414
if ($return_var == 0) {
1515
header("Content-type: application/sql");
16-
header("Content-Disposition: attachment; filename=\"" . $_GET["database"] . ".sql\";");
17-
header("X-Accel-Redirect: " . $output[0]);
16+
header("Content-Disposition: attachment; filename=" . $output[0]);
17+
header("X-Accel-Redirect: " . $output[1]);
1818
}

0 commit comments

Comments
 (0)