Adding rsync exclude support

This commit is contained in:
Matt Jones 2020-01-20 12:15:42 +00:00
parent 8877d68d43
commit e10354130d
No known key found for this signature in database
GPG key ID: 6986F1BFD32F5BB0
2 changed files with 15 additions and 1 deletions

View file

@ -34,6 +34,11 @@ DEV_ACTIVATED_PLUGINS=""

# Plugins deactivated on sync
DEV_DEACTIVATED_PLUGINS=""

# Dirs to exclude from sync
# Multiple dirs can be provided by separating with a comma
# Use dir names or paths relative to uploads dir
DEV_SYNC_DIR_EXCLUDES=""
```

3. Run `wp sync` from the project root.

View file

@ -73,9 +73,18 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
* TASK: Sync Uploads Folder
*/
$task_name = 'Sync Uploads Folder';

$excludes = '';
if ($exclude_dirs = env('DEV_SYNC_DIR_EXCLUDES')) {
$exclude_dirs = explode(',', $exclude_dirs);
foreach ($exclude_dirs as $dir) {
$excludes .= ' --exclude=' . $dir;
}
}

if (`which rsync`) {
task_message($task_name);
$command = 'rsync -avhP '.$ssh_username.'@'.$ssh_hostname.':'.$rem_proj_loc.'/web/app/uploads/ ./web/app/uploads/';
$command = 'rsync -avhP '.$ssh_username.'@'.$ssh_hostname.':'.$rem_proj_loc.'/web/app/uploads/ ./web/app/uploads/' . $excludes;
system($command);
} else {
task_message($task_name.' task not ran, please install \'rsync\'', 'Error', 31);