From 370c6af687c7d03e5652c9b083a075cc0e348ccf Mon Sep 17 00:00:00 2001
From: Dominik <info@profi-webdesign.com>
Date: Sun, 11 Jan 2015 09:39:27 -0500
Subject: [PATCH] Added Mail-Backup remote-functions Fixed error in Mail-Backup-Cron-Task (created file /dev/nul - missing l)
---
server/lib/classes/cron.d/500-backup_mail.inc.php | 45 ++++++++++++++++++++++++---------------------
1 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/server/lib/classes/cron.d/500-backup_mail.inc.php b/server/lib/classes/cron.d/500-backup_mail.inc.php
index 66006fd..55f7690 100644
--- a/server/lib/classes/cron.d/500-backup_mail.inc.php
+++ b/server/lib/classes/cron.d/500-backup_mail.inc.php
@@ -80,10 +80,33 @@
$domain = $temp[1];
unset($temp);;
$domain_rec=$app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain = ?", $domain);
+
+ $backupusername = 'root';
+ $backupgroup = 'root';
+ if ($global_config['backups_include_into_web_quota'] == 'y') {
+ // this only works, if mail and webdomains are on the same server
+ // find webdomain fitting to maildomain
+ $sql = "SELECT * FROM web_domain WHERE domain = '".$domain_rec['domain']."'";
+ $webdomain = $app->db->queryOneRecord($sql);
+ // if this is not also the website, find website now
+ if ($webdomain && ($webdomain['parent_domain_id'] != 0)) {
+ do {
+ $sql = "SELECT * FROM web_domain WHERE domain_id = ".$webdomain['parent_domain_id'];
+ $webdomain = $app->db->queryOneRecord($sql);
+ } while ($webdomain && ($webdomain['parent_domain_id'] != 0));
+ }
+ // if webdomain is found, change username/group now
+ if ($webdomain) {
+ $backupusername = $webdomain['system_user'];
+ $backupgroup = $webdomain['system_group'];
+ }
+ }
$mail_backup_dir = $backup_dir.'/mail'.$domain_rec['domain_id'];
if(!is_dir($mail_backup_dir)) mkdir($mail_backup_dir, 0750);
chmod($mail_backup_dir, $backup_dir_permissions);
+ chown($mail_backup_dir, $backupusername);
+ chgrp($mail_backup_dir, $backupgroup);
$mail_backup_file = 'mail'.$rec['mailuser_id'].'_'.date('Y-m-d_H-i');
@@ -98,33 +121,13 @@
//* create archives
if($backup_mode == 'userzip') {
$mail_backup_file.='.zip';
- exec('cd '.$domain_dir.' && zip '.$mail_backup_dir.'/'.$mail_backup_file.' -b /tmp -r '.$source_dir.' > /dev/nul', $tmp_output, $retval);
+ exec('cd '.$domain_dir.' && zip '.$mail_backup_dir.'/'.$mail_backup_file.' -b /tmp -r '.$source_dir.' > /dev/null', $tmp_output, $retval);
} else {
/* Create a tar.gz backup */
$mail_backup_file.='.tar.gz';
exec(escapeshellcmd('tar pczf '.$mail_backup_dir.'/'.$mail_backup_file.' --directory '.$domain_dir.' '.$source_dir), $tmp_output, $retval);
}
if($retval == 0){
- $backupusername = 'root';
- $backupgroup = 'root';
- if ($global_config['backups_include_into_web_quota'] == 'y') {
- // this only works, if mail and webdomains are on the same server
- // find webdomain fitting to maildomain
- $sql = "SELECT * FROM web_domain WHERE domain = ".$domain_rec['domain'];
- $webdomain = $app->db->queryOneRecord($sql);
- // if this is not also the website, find website now
- if ($webdomain && ($webdomain['parent_domain_id'] != 0)) {
- do {
- $sql = "SELECT * FROM web_domain WHERE domain_id = ".$domain_rec['parent_domain_id'];
- $webdomain = $app->db->queryOneRecord($sql);
- } while ($webdomain && ($webdomain['parent_domain_id'] != 0));
- }
- // if webdomain is found, change username/group now
- if ($webdomain) {
- $backupusername = $webdomain['system_user'];
- $backupgroup = $webdomain['system_group'];
- }
- }
chown($mail_backup_dir.'/'.$mail_backup_file, $backupusername);
chgrp($mail_backup_dir.'/'.$mail_backup_file, $backupgroup);
chmod($mail_backup_dir.'/'.$mail_backup_file, 0640);
--
Gitblit v1.9.1