backup pages

This commit is contained in:
Serghey Rodin 2012-06-28 14:11:35 +03:00
commit 7a99bd4ad0
7 changed files with 153 additions and 4 deletions

View file

@ -390,6 +390,9 @@ local_backup(){
chown nginx:$user $BACKUP/$user.$DATE.tar chown nginx:$user $BACKUP/$user.$DATE.tar
localbackup='yes' localbackup='yes'
echo echo
U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l)
update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS"
} }

53
bin/v_delete_user_backup Executable file
View file

@ -0,0 +1,53 @@
#!/bin/bash
# info: delete user backup
# options: user nackup
#
# The function deletes user backup.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
backup=$(echo $2| cut -f 2 -d \.)
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'user backup'
validate_format 'user' 'backup'
is_system_enabled "$BACKUP_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'backup' 'BACKUP' "$2"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Deleting backup
rm -f $BACKUP/$2
sed -i "/BACKUP='$2' /d" $USER_DATA/backup.conf
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Update counter
U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l)
update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS"
# Logging
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -13,6 +13,8 @@ A8=$8
A9=$9 A9=$9
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
HOMEDIR='/home'
BACKUP='/backup'
BACKUP_GZIP=5 BACKUP_GZIP=5
BACKUP_DISK_LIMIT=95 BACKUP_DISK_LIMIT=95
BACKUP_LA_LIMIT=5 BACKUP_LA_LIMIT=5

View file

@ -0,0 +1,17 @@
<?php
// Init
error_reporting(NULL);
ob_start();
session_start();
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
if ($_SESSION['user'] == 'admin') {
if (!empty($_GET['backup'])) {
$v_username = escapeshellarg($user);
$v_backup = escapeshellarg($_GET['backup']);
exec (VESTA_CMD."v_delete_user_backup ".$v_username." ".$v_backup, $output, $return_var);
unset($output);
}
}
header("Location: /list/backup/");

View file

@ -0,0 +1,23 @@
<?php
// Init
error_reporting(NULL);
session_start();
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
$backup = $_GET['backup'];
// Data
if ($_SESSION['user'] == 'admin') {
header('Content-type: application/gzip');
header("Content-Disposition: attachment; filename=\"".$backup."\";" );
header("X-Accel-Redirect: /backup/" . $backup);
}
if ((!empty($_SESSION['user'])) && ($_SESSION['user'] != 'admin')) {
if (preg_match("/^".$user."/i", $backup)) {
header('Content-type: application/gzip');
header("Content-Disposition: attachment; filename=\"".$backup."\";" );
header("X-Accel-Redirect: /backup/" . $backup);
}
}
?>

View file

@ -13,7 +13,46 @@ foreach ($data as $key => $value) {
if (!empty($data[$key]['MAIL'])) $mail = 'yes ¨'; if (!empty($data[$key]['MAIL'])) $mail = 'yes ¨';
if (!empty($data[$key]['DB'])) $db = 'yes ¨'; if (!empty($data[$key]['DB'])) $db = 'yes ¨';
?> ?>
<script type="text/javascript">
$(function(){
$('#restore_dialog_<?php echo "$i" ?>').dialog({
modal: true,
autoOpen: false,
width: 360,
buttons: {
"Ok": function(event, ui) {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
$('#restore_link_<?php echo "$i" ?>').click(function(){
$('#restore_dialog_<?php echo "$i" ?>').dialog('open');
return false;
});
$('#delete_dialog_<?php echo "$i" ?>').dialog({
modal: true,
autoOpen: false,
width: 360,
buttons: {
"Ok": function(event, ui) {
location.href = '/delete/backup/?backup=<?php echo "$key" ?>';
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
$('#delete_link_<?php echo "$i" ?>').click(function(){
$('#delete_dialog_<?php echo "$i" ?>').dialog('open');
return false;
});
});
</script>
<tr class="data-row"> <tr class="data-row">
<td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150"> <td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
<table class="data-col1"> <table class="data-col1">
@ -25,9 +64,21 @@ foreach ($data as $key => $value) {
<td class="data-dotted" width="830px" style="vertical-align:top;"> <td class="data-dotted" width="830px" style="vertical-align:top;">
<table width="830px"><tr> <table width="830px"><tr>
<td></td> <td></td>
<td class="data-controls" width="80px"><img src="/images/download.png" width="8px" height="8px"><a href="#"> download</a></td> <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>
<td class="data-controls" width="70px"><img src="/images/restore.png" width="6px" height="8px"><a href="#"> restore</a></td> <td class="data-controls" width="80px">
<td class="data-controls" width="70px"><img src="/images/delete.png" width="7px" height="7px"><a href="#"> delete</a></td> <img src="/images/restore.png" width="6px" height="8px">
<a href="#" id="restore_link_<?php echo "$i"?>"> restore</a>
<div id="restore_dialog_<?php echo "$i" ?>" title="Confirmation">
<p class="counter-value">Are you sure you want to restore <b><?php echo "$key" ?></b> backup?</p>
</div>
</td>
<td class="data-controls" width="70px">
<img src="/images/delete.png" width="7px" height="7px">
<a href="#" id="delete_link_<?php echo $i ?>"> delete</a>
<div id="delete_dialog_<?php echo $i ?>" title="Confirmation">
<p class="counter-value">Are you sure you want to delete <b><?php echo "$key" ?></b> backup?</p>
</div>
</td>
</tr></table> </tr></table>
<table class="data-col2" width="830px"> <table class="data-col2" width="830px">

View file

@ -1,7 +1,7 @@
<table class="sub-menu"> <table class="sub-menu">
<tr> <tr>
<td width="142px" style="padding: 16px 0 16px 6px"> <td width="142px" style="padding: 16px 0 16px 6px">
<button style="width:120px; padding: 2px 0px 2px 0px;" onclick="location.href='/add/backup/'">Add Backup</button> <button style="width:120px; padding: 2px 0px 2px 0px;" onclick="location.href='#'"> Backup Now</button>
<td><a style="padding: 0 4px 0 12px" class="select-controls" href='javascript:checkedAll("vstobjects");'> toggle all </a> <td><a style="padding: 0 4px 0 12px" class="select-controls" href='javascript:checkedAll("vstobjects");'> toggle all </a>
<select style="margin:0 0 0 0px"> <select style="margin:0 0 0 0px">
<option>apply to selected</option> <option>apply to selected</option>