@@ -132,21 +132,37 @@ function copy_site_certs( Site $source, Site $destination ) {
132132
133133function copy_site_files ( Site $ source , Site $ destination , array $ sync_type ) {
134134
135- $ exclude = '--exclude \'/wp-config.php \'' ;
136- $ source_public_path = str_replace ( '/var/www/htdocs ' , '' , $ source ->site_details ['site_container_fs_path ' ] );
137- $ uploads_path = $ source_public_path . '/wp-content/uploads ' ;
138- $ uploads_path_share = '/shared/wp-content/uploads ' ;
135+ $ source_public_path = str_replace ( '/var/www/htdocs ' , '' , $ source ->site_details ['site_container_fs_path ' ] );
136+ $ destination_public_path = str_replace ( '/var/www/htdocs ' , '' , $ destination ->site_details ['site_container_fs_path ' ] );
137+
138+ $ exclude = '--exclude \'/wp-config.php \'' ;
139+
140+ // Exclude wp-config.php from source's custom public directory structure.
141+ // rsync --exclude patterns are relative to the source directory being synced.
142+ if ( ! empty ( $ source_public_path ) ) {
143+ $ exclude .= ' --exclude \'' . $ source_public_path . '/wp-config.php \'' ;
144+
145+ // Also exclude wp-config.php one level up from public directory (WordPress convention).
146+ $ parent_dir = dirname ( $ source_public_path );
147+ if ( $ parent_dir !== '. ' && $ parent_dir !== '/ ' ) {
148+ $ exclude .= ' --exclude \'' . $ parent_dir . '/wp-config.php \'' ;
149+ }
150+ }
151+
152+ $ source_uploads_path = $ source_public_path . '/wp-content/uploads ' ;
153+ $ destination_uploads_path = $ destination_public_path . '/wp-content/uploads ' ;
154+ $ uploads_path_share = '/shared/wp-content/uploads ' ;
139155
140156 $ source_dir = remove_trailing_slash ( $ source ->get_site_root_dir () );
141157 $ destination_dir = remove_trailing_slash ( $ destination ->get_site_root_dir () );
142158
143159 if ( $ sync_type ['uploads ' ] && ! $ sync_type ['files ' ] ) {
144- $ source_dir .= $ uploads_path ;
145- $ destination_dir .= $ uploads_path ;
160+ $ source_dir .= $ source_uploads_path ;
161+ $ destination_dir .= $ destination_uploads_path ;
146162 }
147163
148164 if ( $ sync_type ['files ' ] && ! $ sync_type ['uploads ' ] ) {
149- $ exclude .= ' --exclude \'' . $ uploads_path . '\'' ;
165+ $ exclude .= ' --exclude \'' . $ source_uploads_path . '\'' ;
150166 $ exclude .= ' --exclude \'' . $ uploads_path_share . '\'' ;
151167 }
152168
0 commit comments