Skip to content

Commit fecff90

Browse files
author
Marius Cramer
committed
Fixed: FS#3287 - Fix issue with empty .zip files in .zip mode of the backup function.
1 parent c1bef89 commit fecff90

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

server/lib/classes/cron.d/500-backup.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ public function onRunJob() {
9898
//* Create a .zip backup as web user and include also files owned by apache / nginx user
9999
$web_backup_file = 'web'.$web_id.'_'.date('Y-m-d_H-i').'.zip';
100100
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);
101-
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);
101+
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\* --update --symlinks '.escapeshellarg($web_backup_dir.'/'.$web_backup_file).' -@', $tmp_output, $retval);
102102
} else {
103103
//* Create a tar.gz backup as root user
104104
$web_backup_file = 'web'.$web_id.'_'.date('Y-m-d_H-i').'.tar.gz';
105105
exec('tar pczf '.escapeshellarg($web_backup_dir.'/'.$web_backup_file).' --exclude=backup\* --directory '.escapeshellarg($web_path).' .', $tmp_output, $retval);
106106
}
107-
if($retval == 0){
107+
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
108108
chown($web_backup_dir.'/'.$web_backup_file, 'root');
109109
chgrp($web_backup_dir.'/'.$web_backup_file, 'root');
110110
chmod($web_backup_dir.'/'.$web_backup_file, 0750);

0 commit comments

Comments
 (0)