From 98dd6b9d5d27652dd08f4ba91193b37227154464 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Mon, 7 Apr 2014 23:51:21 +0300 Subject: [PATCH] backup exclusions --- web/edit/backup/exclusions/index.php | 115 ++++++++++++++++++ web/inc/i18n/en.php | 5 + web/list/backup/exclusions/index.php | 24 ++++ .../admin/edit_backup_exclusions.html | 104 ++++++++++++++++ web/templates/admin/list_backup.html | 7 +- .../admin/list_backup_exclusions.html | 93 ++++++++++++++ 6 files changed, 346 insertions(+), 2 deletions(-) create mode 100644 web/edit/backup/exclusions/index.php create mode 100644 web/list/backup/exclusions/index.php create mode 100644 web/templates/admin/edit_backup_exclusions.html create mode 100644 web/templates/admin/list_backup_exclusions.html diff --git a/web/edit/backup/exclusions/index.php b/web/edit/backup/exclusions/index.php new file mode 100644 index 000000000..a40f8d558 --- /dev/null +++ b/web/edit/backup/exclusions/index.php @@ -0,0 +1,115 @@ + $value) { + if (!empty($value)){ + $v_web .= $key . ":" . $value. "\n"; + } else { + $v_web .= $key . "\n"; + } + } + + foreach ($data['DNS'] as $key => $value) { + if (!empty($value)){ + $v_dns .= $key . ":" . $value. "\n"; + } else { + $v_dns .= $key . "\n"; + } + } + + foreach ($data['MAIL'] as $key => $value) { + if (!empty($value)){ + $v_mail .= $key . ":" . $value. "\n"; + } else { + $v_mail .= $key . "\n"; + } + } + + foreach ($data['DB'] as $key => $value) { + if (!empty($value)){ + $v_db .= $key . ":" . $value. "\n"; + } else { + $v_db .= $key . "\n"; + } + } + + foreach ($data['USER'] as $key => $value) { + if (!empty($value)){ + $v_userdir .= $key . ":" . $value. "\n"; + } else { + $v_userdir .= $key . "\n"; + } + } + + + // Action + if (!empty($_POST['save'])) { + + $v_web = $_POST['v_web']; + $v_web_tmp = str_replace("\r\n", ",", $_POST['v_web']); + $v_web_tmp = rtrim($v_web_tmp, ","); + $v_web_tmp = "WEB=" . escapeshellarg($v_web_tmp); + + $v_dns = $_POST['v_dns']; + $v_dns_tmp = str_replace("\r\n", ",", $_POST['v_dns']); + $v_dns_tmp = rtrim($v_dns_tmp, ","); + $v_dns_tmp = "DNS=" . escapeshellarg($v_dns_tmp); + + $v_mail = $_POST['v_mail']; + $v_mail_tmp = str_replace("\r\n", ",", $_POST['v_mail']); + $v_mail_tmp = rtrim($v_mail_tmp, ","); + $v_mail_tmp = "MAIL=" . escapeshellarg($v_mail_tmp); + + $v_db = $_POST['v_db']; + $v_db_tmp = str_replace("\r\n", ",", $_POST['v_db']); + $v_db_tmp = rtrim($v_db_tmp, ","); + $v_db_tmp = "DB=" . escapeshellarg($v_db_tmp); + + $v_userdir = $_POST['v_userdir']; + $v_userdir_tmp = str_replace("\r\n", ",", $_POST['v_userdir']); + $v_userdir_tmp = rtrim($v_userdir_tmp, ","); + $v_userdir_tmp = "USER=" . escapeshellarg($v_userdir_tmp); + + exec ('mktemp', $mktemp_output, $return_var); + $tmp = $mktemp_output[0]; + $fp = fopen($tmp, 'w'); + fwrite($fp, $v_web_tmp . "\n" . $v_dns_tmp . "\n" . $v_mail_tmp . "\n" . $v_db_tmp . "\n" . $v_userdir_tmp . "\n"); + fclose($fp); + exec (VESTA_CMD."v-update-user-backup-exclusions ".$user." ".$tmp, $output, $return_var); + check_return_code($return_var,$output); + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = __("Changes has been saved."); + } + } +} + +include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_backup_exclusions.html'); +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/inc/i18n/en.php b/web/inc/i18n/en.php index 3a98b71bf..9377690f9 100644 --- a/web/inc/i18n/en.php +++ b/web/inc/i18n/en.php @@ -400,6 +400,11 @@ $LANG['en'] = array( 'RESTORE_SCHEDULED' => 'Task has been added to the queue. You will receive an email notification when your backup is ready for download.', 'RESTORE_EXISTS' => 'An existing restoration task is already running. Please wait for it to finish before launching it again.', + 'WEB_EXCLUSIONS' => "Type domain name, one per line. To exlude all domains use *. To exclude specific dirs use following format: domain.com:public_html/cache:public_html/tmp", + 'DNS_EXCLUSIONS' => "Type domain name, one per line. To exlude all domains use *", + 'MAIL_EXCLUSIONS' => "Type domain name, one per line. To exlude all domains use *. To exclude specific accounts use following format: domain.com:info:support:postmaster", + 'DB_EXCLUSIONS' => "Type full database name, one per line. To exlude all databases use *", + 'USER_EXCLUSIONS' => "Type directory name, one per line. Directories should not include leading or trailing slashes. To exlude all dirs use *", 'Welcome to Vesta Control Panel' => 'Welcome to Vesta Control Panel', 'MAIL_FROM' => 'Vesta Control Panel ', diff --git a/web/list/backup/exclusions/index.php b/web/list/backup/exclusions/index.php new file mode 100644 index 000000000..8c5f88869 --- /dev/null +++ b/web/list/backup/exclusions/index.php @@ -0,0 +1,24 @@ + + + + + + + + +
+ + + + + +
+ + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + +
+
+
diff --git a/web/templates/admin/list_backup.html b/web/templates/admin/list_backup.html index a888ef014..837c5b81c 100644 --- a/web/templates/admin/list_backup.html +++ b/web/templates/admin/list_backup.html @@ -7,7 +7,7 @@ + diff --git a/web/templates/admin/list_backup_exclusions.html b/web/templates/admin/list_backup_exclusions.html new file mode 100644 index 000000000..bdb1ecdb5 --- /dev/null +++ b/web/templates/admin/list_backup_exclusions.html @@ -0,0 +1,93 @@ + + + + + + + +
+ + + $value) { + ?> + + + + + + + + +
+ + +
+
+ + + + + " /> + + + + + + + + +
+ + + + + $ex_value) { + ?> + + + + + +
+
+
+ + + + + + + +
+ ... +
+
+