Skip to content

Commit a85aa52

Browse files
committed
delete backup exclusions
1 parent 5edb660 commit a85aa52

File tree

5 files changed

+132
-4
lines changed

5 files changed

+132
-4
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
# info: delete backup exclusion
3+
# options: USER [SYSTEM]
4+
#
5+
# The function for deleteing backup exclusion
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
system=$(echo $2 | tr '[:lower:]' '[:upper:]')
15+
16+
# Includes
17+
source $VESTA/func/main.sh
18+
source $VESTA/conf/vesta.conf
19+
20+
21+
#----------------------------------------------------------#
22+
# Verifications #
23+
#----------------------------------------------------------#
24+
25+
check_args '1' "$#" 'USER [SYSTEM]'
26+
validate_format 'user'
27+
is_object_valid 'user' 'USER' "$user"
28+
29+
30+
#----------------------------------------------------------#
31+
# Action #
32+
#----------------------------------------------------------#
33+
34+
# Delete system exclusion
35+
if [ -z "$system" ]; then
36+
WEB=''
37+
DNS=''
38+
MAIL=''
39+
DB=''
40+
CRON=''
41+
USER=''
42+
else
43+
touch $USER_DATA/backup-excludes.conf
44+
source $USER_DATA/backup-excludes.conf
45+
case $system in
46+
WEB) WEB='';;
47+
DNS) DNS='';;
48+
MAIL) MAIL='';;
49+
DB) DB='';;
50+
CRON) CRON='';;
51+
USER) USER='';;
52+
esac
53+
fi
54+
55+
# Updating exlusion list
56+
echo "WEB='$WEB'" > $USER_DATA/backup-excludes.conf
57+
echo "DNS='$DNS'" >> $USER_DATA/backup-excludes.conf
58+
echo "MAIL='$MAIL'" >> $USER_DATA/backup-excludes.conf
59+
echo "DB='$DB'" >> $USER_DATA/backup-excludes.conf
60+
echo "CRON='$DB'" >> $USER_DATA/backup-excludes.conf
61+
echo "USER='$USER'" >> $USER_DATA/backup-excludes.conf
62+
chmod 660 $USER_DATA/backup-excludes.conf
63+
64+
65+
#----------------------------------------------------------#
66+
# Vesta #
67+
#----------------------------------------------------------#
68+
69+
# Logging
70+
if [ -z "$system" ]; then
71+
log_history "deleted all exlusions"
72+
else
73+
log_history "deleted $system exlusion"
74+
fi
75+
log_event "$OK" "$EVENT"
76+
77+
exit
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+
ob_start();
5+
session_start();
6+
7+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
8+
9+
$backup = $_POST['system'];
10+
$action = $_POST['action'];
11+
12+
switch ($action) {
13+
case 'delete': $cmd='v-delete-user-backup-exclusions';
14+
break;
15+
default: header("Location: /list/backup/exclusions"); exit;
16+
}
17+
18+
foreach ($backup as $value) {
19+
$value = escapeshellarg($value);
20+
exec (VESTA_CMD.$cmd." ".$user." ".$value, $output, $return_var);
21+
}
22+
23+
header("Location: /list/backup/exclusions");
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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') && (!empty($_GET['user']))) {
9+
$user=$_GET['user'];
10+
}
11+
12+
if (!empty($_GET['system'])) {
13+
$v_username = escapeshellarg($user);
14+
$v_system = escapeshellarg($_GET['system']);
15+
exec (VESTA_CMD."v-delete-user-backup-exclusions ".$v_username." ".$v_system, $output, $return_var);
16+
}
17+
check_return_code($return_var,$output);
18+
unset($output);
19+
20+
$back = $_SESSION['back'];
21+
if (!empty($back)) {
22+
header("Location: ".$back);
23+
exit;
24+
}
25+
26+
header("Location: /list/backup/exclusions/");
27+
exit;

web/inc/i18n/en.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@
382382
'SUSPEND_CRON_CONFIRMATION' => 'Are you sure to suspend cron job?',
383383
'UNSUSPEND_CRON_CONFIRMATION' => 'Are you sure to unsuspend cron job?',
384384
'DELETE_BACKUP_CONFIRMATION' => 'Are you sure to delete %s backup?',
385+
'DELETE_EXCLUSION_CONFIRMATION' => 'Are you sure to delete %s exclusion?',
385386
'DELETE_PACKAGE_CONFIRMATION' => 'Are you sure to delete package %s?',
386387
'DELETE_IP_CONFIRMATION' => 'Are you sure to delere IP address %s?',
387388
'Welcome' => 'Welcome',

web/templates/admin/list_backup_exclusions.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</form>
1212
</div>
1313
<div class="submenu-select-block">
14-
<form action="/bulk/backup/" method="post" id="objects">
14+
<form action="/bulk/backup/exclusions/" method="post" id="objects">
1515
<a class="submenu-select-link" href='javascript:checkedAll("objects");'> <?php print __('toggle all');?> </a>
1616
<select class="submenu-select-dropdown" name="action">
1717
<option value=""><?php print __('apply to selected');?></option>
@@ -35,17 +35,17 @@
3535
<tr class="data-row">
3636
<td class="data-dotted">
3737
<table class="data-col1">
38-
<tr><td><input type="checkbox" class="ch-toggle" name="exclusion[]" value="<?php echo $key ?>" ></td></tr>
38+
<tr><td><input type="checkbox" class="ch-toggle" name="system[]" value="<?php echo $key ?>" ></td></tr>
3939
</table>
4040
</td>
4141
<td class="data-dotted" width="830px">
4242
<a id="delete_link_<?php echo $i ?>" class="data-controls do_delete">
4343
<span class="do_delete">
4444
<img src="/images/delete.png" width="7px" height="7px">
4545
<?php print __('delete');?>
46-
<input type="hidden" name="delete_url" value="/delete/backup/exclusion/?excl=<?php echo "$key" ?>" />
46+
<input type="hidden" name="delete_url" value="/delete/backup/exclusion/?system=<?php echo "$key" ?>" />
4747
<div id="delete_dialog_<?php echo $i ?>" class="confirmation-text-delete hidden" title="<?php print __('Confirmation');?>">
48-
<p class="counter-value"><?php print __('DELETE_BACKUP_CONFIRMATION',$key);?></p>
48+
<p class="counter-value"><?php print __('DELETE_EXCLUSION_CONFIRMATION',$key);?></p>
4949
</div>
5050
</span>
5151
</a>

0 commit comments

Comments
 (0)