Marius Cramer
2014-01-28 f753744a1ff4309771a5faf8d9002d7b211b9dd4
Fixed: FS#3287 - Fix issue with empty .zip files in .zip mode of the backup function.
1 files modified
4 ■■■■ changed files
server/cron_daily.php 4 ●●●● patch | view | raw | blame | history
server/cron_daily.php
@@ -1154,13 +1154,13 @@
                        //* 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\*'.$backup_excludes.' --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);
                        if($retval == 0 || $retval == 12) 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\*'.$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($retval == 0 || ($backup_mode != 'userzip' && $retval == 1) || ($backup_mode == 'userzip' && $retval == 12)) { // tar can return 1, zip can return 12(due to harmless warings) and still create valid backups
                        if(is_file($web_backup_dir.'/'.$web_backup_file)){
                            chown($web_backup_dir.'/'.$web_backup_file, 'root');
                            chgrp($web_backup_dir.'/'.$web_backup_file, 'root');