Skip to content

Commit 7a99bd4

Browse files
committed
backup pages
1 parent b0d5764 commit 7a99bd4

File tree

7 files changed

+153
-4
lines changed

7 files changed

+153
-4
lines changed

bin/v_backup_user

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ local_backup(){
390390
chown nginx:$user $BACKUP/$user.$DATE.tar
391391
localbackup='yes'
392392
echo
393+
394+
U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l)
395+
update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS"
393396
}
394397

395398

bin/v_delete_user_backup

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
# info: delete user backup
3+
# options: user nackup
4+
#
5+
# The function deletes user backup.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
backup=$(echo $2| cut -f 2 -d \.)
15+
16+
# Includes
17+
source $VESTA/conf/vesta.conf
18+
source $VESTA/func/main.sh
19+
20+
21+
#----------------------------------------------------------#
22+
# Verifications #
23+
#----------------------------------------------------------#
24+
25+
check_args '2' "$#" 'user backup'
26+
validate_format 'user' 'backup'
27+
is_system_enabled "$BACKUP_SYSTEM"
28+
is_object_valid 'user' 'USER' "$user"
29+
is_object_unsuspended 'user' 'USER' "$user"
30+
is_object_valid 'backup' 'BACKUP' "$2"
31+
32+
#----------------------------------------------------------#
33+
# Action #
34+
#----------------------------------------------------------#
35+
36+
# Deleting backup
37+
rm -f $BACKUP/$2
38+
sed -i "/BACKUP='$2' /d" $USER_DATA/backup.conf
39+
40+
41+
#----------------------------------------------------------#
42+
# Vesta #
43+
#----------------------------------------------------------#
44+
45+
# Update counter
46+
U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l)
47+
update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS"
48+
49+
# Logging
50+
log_history "$EVENT"
51+
log_event "$OK" "$EVENT"
52+
53+
exit

func/main.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ A8=$8
1313
A9=$9
1414
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
1515
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
16+
HOMEDIR='/home'
17+
BACKUP='/backup'
1618
BACKUP_GZIP=5
1719
BACKUP_DISK_LIMIT=95
1820
BACKUP_LA_LIMIT=5

web/delete/backup/index.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
// Init
3+
error_reporting(NULL);
4+
ob_start();
5+
session_start();
6+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
7+
8+
if ($_SESSION['user'] == 'admin') {
9+
if (!empty($_GET['backup'])) {
10+
$v_username = escapeshellarg($user);
11+
$v_backup = escapeshellarg($_GET['backup']);
12+
exec (VESTA_CMD."v_delete_user_backup ".$v_username." ".$v_backup, $output, $return_var);
13+
unset($output);
14+
}
15+
}
16+
17+
header("Location: /list/backup/");

web/download/backup/index.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
// Init
3+
error_reporting(NULL);
4+
session_start();
5+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
6+
$backup = $_GET['backup'];
7+
8+
// Data
9+
if ($_SESSION['user'] == 'admin') {
10+
header('Content-type: application/gzip');
11+
header("Content-Disposition: attachment; filename=\"".$backup."\";" );
12+
header("X-Accel-Redirect: /backup/" . $backup);
13+
}
14+
15+
if ((!empty($_SESSION['user'])) && ($_SESSION['user'] != 'admin')) {
16+
if (preg_match("/^".$user."/i", $backup)) {
17+
header('Content-type: application/gzip');
18+
header("Content-Disposition: attachment; filename=\"".$backup."\";" );
19+
header("X-Accel-Redirect: /backup/" . $backup);
20+
}
21+
}
22+
23+
?>

web/templates/admin/list_backup.html

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,46 @@
1313
if (!empty($data[$key]['MAIL'])) $mail = 'yes ¨';
1414
if (!empty($data[$key]['DB'])) $db = 'yes ¨';
1515
?>
16+
<script type="text/javascript">
17+
$(function(){
18+
$('#restore_dialog_<?php echo "$i" ?>').dialog({
19+
modal: true,
20+
autoOpen: false,
21+
width: 360,
22+
buttons: {
23+
"Ok": function(event, ui) {
24+
$(this).dialog("close");
25+
},
26+
"Cancel": function() {
27+
$(this).dialog("close");
28+
}
29+
}
30+
});
31+
$('#restore_link_<?php echo "$i" ?>').click(function(){
32+
$('#restore_dialog_<?php echo "$i" ?>').dialog('open');
33+
return false;
34+
});
1635

36+
$('#delete_dialog_<?php echo "$i" ?>').dialog({
37+
modal: true,
38+
autoOpen: false,
39+
width: 360,
40+
buttons: {
41+
"Ok": function(event, ui) {
42+
location.href = '/delete/backup/?backup=<?php echo "$key" ?>';
43+
},
44+
"Cancel": function() {
45+
$(this).dialog("close");
46+
}
47+
}
48+
});
49+
$('#delete_link_<?php echo "$i" ?>').click(function(){
50+
$('#delete_dialog_<?php echo "$i" ?>').dialog('open');
51+
return false;
52+
});
53+
54+
});
55+
</script>
1756
<tr class="data-row">
1857
<td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
1958
<table class="data-col1">
@@ -25,9 +64,21 @@
2564
<td class="data-dotted" width="830px" style="vertical-align:top;">
2665
<table width="830px"><tr>
2766
<td></td>
28-
<td class="data-controls" width="80px"><img src="/images/download.png" width="8px" height="8px"><a href="#"> download</a></td>
29-
<td class="data-controls" width="70px"><img src="/images/restore.png" width="6px" height="8px"><a href="#"> restore</a></td>
30-
<td class="data-controls" width="70px"><img src="/images/delete.png" width="7px" height="7px"><a href="#"> delete</a></td>
67+
<td class="data-controls" width="80px"><img src="/images/download.png" width="8px" height="8px"><a href="/download/backup/?backup=<?php echo $key ?>" target="_blank"> download</a></td>
68+
<td class="data-controls" width="80px">
69+
<img src="/images/restore.png" width="6px" height="8px">
70+
<a href="#" id="restore_link_<?php echo "$i"?>"> restore</a>
71+
<div id="restore_dialog_<?php echo "$i" ?>" title="Confirmation">
72+
<p class="counter-value">Are you sure you want to restore <b><?php echo "$key" ?></b> backup?</p>
73+
</div>
74+
</td>
75+
<td class="data-controls" width="70px">
76+
<img src="/images/delete.png" width="7px" height="7px">
77+
<a href="#" id="delete_link_<?php echo $i ?>"> delete</a>
78+
<div id="delete_dialog_<?php echo $i ?>" title="Confirmation">
79+
<p class="counter-value">Are you sure you want to delete <b><?php echo "$key" ?></b> backup?</p>
80+
</div>
81+
</td>
3182
</tr></table>
3283

3384
<table class="data-col2" width="830px">

web/templates/admin/menu_backup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<table class="sub-menu">
22
<tr>
33
<td width="142px" style="padding: 16px 0 16px 6px">
4-
<button style="width:120px; padding: 2px 0px 2px 0px;" onclick="location.href='/add/backup/'">Add Backup</button>
4+
<button style="width:120px; padding: 2px 0px 2px 0px;" onclick="location.href='#'"> Backup Now</button>
55
<td><a style="padding: 0 4px 0 12px" class="select-controls" href='javascript:checkedAll("vstobjects");'> toggle all </a>
66
<select style="margin:0 0 0 0px">
77
<option>apply to selected</option>

0 commit comments

Comments
 (0)