From fe5f535946b2270558579f7b09c40199462172b0 Mon Sep 17 00:00:00 2001
From: Falko Timme <ft@falkotimme.com>
Date: Wed, 20 Nov 2013 20:45:35 -0500
Subject: [PATCH] - It is now possible to exclude directories - on a per-vHost base - from website backups.
---
server/cron_daily.php | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/server/cron_daily.php b/server/cron_daily.php
index 60f3c21..cb90582 100644
--- a/server/cron_daily.php
+++ b/server/cron_daily.php
@@ -1127,15 +1127,27 @@
chown($web_backup_dir, 'root');
chgrp($web_backup_dir, 'root');
}*/
+
+ $backup_excludes = '';
+ $b_excludes = explode(',', trim($rec['backup_excludes']));
+ if(is_array($b_excludes) && !empty($b_excludes)){
+ foreach($b_excludes as $b_exclude){
+ $b_exclude = trim($b_exclude);
+ if($b_exclude != ''){
+ $backup_excludes .= ' --exclude='.escapeshellarg($b_exclude);
+ }
+ }
+ }
+
if($backup_mode == 'userzip') {
//* Create a .zip backup as web user and include also files owned by apache / nginx user
$web_backup_file = 'web'.$web_id.'_'.date('Y-m-d_H-i').'.zip';
exec('cd '.escapeshellarg($web_path).' && sudo -u '.escapeshellarg($web_user).' find . -group '.escapeshellarg($web_group).' -print 2> /dev/null | zip -b /tmp --exclude=backup\* --symlinks '.escapeshellarg($web_backup_dir.'/'.$web_backup_file).' -@', $tmp_output, $retval);
- if($retval == 0) exec('cd '.escapeshellarg($web_path).' && sudo -u '.escapeshellarg($web_user).' find . -user '.escapeshellarg($http_server_user).' -print 2> /dev/null | zip -b /tmp --exclude=backup\* --update --symlinks '.escapeshellarg($web_backup_dir.'/'.$web_backup_file).' -@', $tmp_output, $retval);
+ if($retval == 0) exec('cd '.escapeshellarg($web_path).' && sudo -u '.escapeshellarg($web_user).' find . -user '.escapeshellarg($http_server_user).' -print 2> /dev/null | zip -b /tmp --exclude=backup\*'.$backup_excludes.' --update --symlinks '.escapeshellarg($web_backup_dir.'/'.$web_backup_file).' -@', $tmp_output, $retval);
} else {
//* Create a tar.gz backup as root user
$web_backup_file = 'web'.$web_id.'_'.date('Y-m-d_H-i').'.tar.gz';
- exec('tar pczf '.escapeshellarg($web_backup_dir.'/'.$web_backup_file).' --exclude=backup\* --directory '.escapeshellarg($web_path).' .', $tmp_output, $retval);
+ exec('tar pczf '.escapeshellarg($web_backup_dir.'/'.$web_backup_file).' --exclude=backup\*'.$backup_excludes.' --directory '.escapeshellarg($web_path).' .', $tmp_output, $retval);
}
if($retval == 0 || $backup_mode != 'userzip'){ // tar can return 1 (due to harmless warings) and still create valid backups
if(is_file($web_backup_dir.'/'.$web_backup_file)){
--
Gitblit v1.9.1