@@ -419,7 +419,13 @@ private function maybe_backup_custom_docker_compose( $backup_dir ) {
419419 if ( $ this ->fs ->exists ( $ custom_docker_compose_dir ) ) {
420420 $ custom_docker_compose_dir_archive = $ backup_dir . '/user-docker-compose.zip ' ;
421421 $ archive_command = sprintf ( 'cd %s && 7z a -mx=1 %s . ' , $ custom_docker_compose_dir , $ custom_docker_compose_dir_archive );
422- EE ::exec ( $ archive_command );
422+ $ result = EE ::launch ( $ archive_command );
423+
424+ // 7z exit codes: 0=success, 1=warning (non-fatal), 2+=fatal error
425+ // This is optional, so we just log a warning instead of failing
426+ if ( $ result ->return_code >= 2 ) {
427+ EE ::warning ( 'Failed to backup custom docker-compose directory. Continuing with backup. ' );
428+ }
423429 }
424430 }
425431
@@ -431,10 +437,11 @@ private function backup_site_dir( $backup_dir ) {
431437 $ backup_file = $ backup_dir . '/ ' . $ this ->site_data ['site_url ' ] . '.zip ' ;
432438 $ backup_command = sprintf ( 'cd %s && 7z a -mx=1 %s . ' , $ site_dir , $ backup_file );
433439
434- $ result = EE ::exec ( $ backup_command );
440+ $ result = EE ::launch ( $ backup_command );
435441
436- // Check if archive was created successfully
437- if ( ! $ result || ! $ this ->fs ->exists ( $ backup_file ) ) {
442+ // 7z exit codes: 0=success, 1=warning (non-fatal), 2+=fatal error
443+ // Exit code 1 means warnings (e.g., missing symlink targets) but archive is still created
444+ if ( $ result ->return_code >= 2 || ! $ this ->fs ->exists ( $ backup_file ) ) {
438445 $ this ->capture_error (
439446 'Failed to create site backup archive ' ,
440447 self ::ERROR_TYPE_FILESYSTEM ,
@@ -470,9 +477,10 @@ private function backup_wp_content_dir( $backup_dir ) {
470477 }
471478
472479 $ backup_command = sprintf ( 'cd %s && 7z a -mx=1 %s wp-config.php ' , $ site_dir . '/../ ' , $ backup_file );
473- $ result = EE ::exec ( $ backup_command );
480+ $ result = EE ::launch ( $ backup_command );
474481
475- if ( ! $ result ) {
482+ // 7z exit codes: 0=success, 1=warning (non-fatal), 2+=fatal error
483+ if ( $ result ->return_code >= 2 || ! $ this ->fs ->exists ( $ backup_file ) ) {
476484 $ this ->capture_error (
477485 'Failed to create WordPress content backup archive ' ,
478486 self ::ERROR_TYPE_FILESYSTEM ,
@@ -486,15 +494,34 @@ private function backup_wp_content_dir( $backup_dir ) {
486494
487495 // Include meta.json in the zip archive (Corrected logic)
488496 $ backup_command = sprintf ( 'cd %s && 7z u -snl -mx=1 %s %s wp-content ' , $ site_dir , $ backup_file , $ meta_file );
489- EE ::exec ( $ backup_command );
497+ $ result = EE ::launch ( $ backup_command );
490498 // Remove the file
491499 $ this ->fs ->remove ( $ meta_file );
492500
501+ // 7z exit codes: 0=success, 1=warning (non-fatal), 2+=fatal error
502+ if ( $ result ->return_code >= 2 || ! $ this ->fs ->exists ( $ backup_file ) ) {
503+ $ this ->capture_error (
504+ 'Failed to create WordPress content backup archive ' ,
505+ self ::ERROR_TYPE_FILESYSTEM ,
506+ 3002
507+ );
508+ EE ::error ( 'Failed to create backup archive. Please check disk space and file permissions. ' );
509+ }
493510
494511 $ uploads_dir = $ site_dir . '/wp-content/uploads ' ;
495512 if ( is_link ( $ uploads_dir ) ) {
496513 $ backup_command = sprintf ( 'cd %s && 7z u -mx=1 %s wp-content/uploads ' , $ site_dir , $ backup_file );
497- EE ::exec ( $ backup_command );
514+ $ result = EE ::launch ( $ backup_command );
515+
516+ // 7z exit codes: 0=success, 1=warning (non-fatal), 2+=fatal error
517+ if ( $ result ->return_code >= 2 ) {
518+ $ this ->capture_error (
519+ 'Failed to create WordPress content backup archive ' ,
520+ self ::ERROR_TYPE_FILESYSTEM ,
521+ 3002
522+ );
523+ EE ::error ( 'Failed to create backup archive. Please check disk space and file permissions. ' );
524+ }
498525 }
499526
500527 // Final check that backup file was created successfully
@@ -517,9 +544,10 @@ private function backup_nginx_conf( $backup_dir ) {
517544 $ backup_file = $ backup_dir . '/conf.zip ' ;
518545 $ backup_command = sprintf ( 'cd %s && 7z a -mx=1 %s nginx ' , $ conf_dir , $ backup_file );
519546
520- $ result = EE ::exec ( $ backup_command );
547+ $ result = EE ::launch ( $ backup_command );
521548
522- if ( ! $ result ) {
549+ // 7z exit codes: 0=success, 1=warning (non-fatal), 2+=fatal error
550+ if ( $ result ->return_code >= 2 || ! $ this ->fs ->exists ( $ backup_file ) ) {
523551 $ this ->capture_error (
524552 'Failed to create nginx configuration backup archive ' ,
525553 self ::ERROR_TYPE_FILESYSTEM ,
@@ -536,9 +564,10 @@ private function backup_php_conf( $backup_dir ) {
536564 $ backup_file = $ backup_dir . '/conf.zip ' ;
537565 $ backup_command = sprintf ( 'cd %s && 7z u -mx=1 %s php ' , $ conf_dir , $ backup_file );
538566
539- $ result = EE ::exec ( $ backup_command );
567+ $ result = EE ::launch ( $ backup_command );
540568
541- if ( ! $ result ) {
569+ // 7z exit codes: 0=success, 1=warning (non-fatal), 2+=fatal error
570+ if ( $ result ->return_code >= 2 || ! $ this ->fs ->exists ( $ backup_file ) ) {
542571 $ this ->capture_error (
543572 'Failed to create PHP configuration backup archive ' ,
544573 self ::ERROR_TYPE_FILESYSTEM ,
@@ -610,15 +639,18 @@ private function backup_db( $backup_dir ) {
610639 EE ::exec ( sprintf ( 'mv %s %s ' , $ sql_dump_path , $ sql_file ) );
611640 $ backup_command = sprintf ( 'cd %s && 7z u -mx=1 %s sql ' , $ backup_dir , $ backup_file );
612641
613- $ result = EE ::exec ( $ backup_command );
614- if ( ! $ result ) {
642+ $ result = EE ::launch ( $ backup_command );
643+
644+ // 7z exit codes: 0=success, 1=warning (non-fatal), 2+=fatal error
645+ if ( $ result ->return_code >= 2 || ! $ this ->fs ->exists ( $ backup_file ) ) {
615646 $ this ->capture_error (
616647 'Failed to compress database backup into archive ' ,
617648 self ::ERROR_TYPE_FILESYSTEM ,
618649 3002
619650 );
620651 EE ::error ( 'Failed to compress database backup. Please check disk space. ' );
621652 }
653+
622654 $ this ->fs ->remove ( $ backup_dir . '/sql ' );
623655 }
624656
0 commit comments