littlebizzy / slickstack

Lightning-fast WordPress on Nginx
https://slickstack.io
GNU General Public License v3.0
624 stars 113 forks source link

ss-sync-staging excluding any file with "uploads" in the filename #167

Closed BHare1985 closed 1 year ago

BHare1985 commented 2 years ago

Wordpress broke when I installed elementor and synced to staging.

the elementor file wp-content/plugins/elementor/core/files/uploads-manager.php was being excluded from the sync.

Issue was an over-reaching exclude in the rsync in ss-sync-staging the command ss_rsync --max-size=5mb --exclude="mu-plugins*" --exclude="uploads*" /var/www/html/wp-content/ /var/www/html/staging/wp-content should use --exclude="/uploads/*" or --exclude="uploads/*" instead of a wildcard of any file with the word uploads.

jessuppi commented 2 years ago

Thanks again @BHare1985

As I mentioned on Discord I couldn't remember why we used that syntax, but I vaguely recalled having issues when trying to exclude the directory using slashes such as `--exclude="/uploads/" or similar to that.

And sure enough, I see other bloggers saying to avoid the slashes:

https://linuxhint.com/exclude-directory-rsync/ https://linuxconfig.org/rsync-exclude-directory

However, in the 2nd link I see they use an example with no quotation marks... I'm wondering if the string is interpreted differently because our script uses quotation marks, so it's being applied to random PHP files too?

I have made some small tweaks: https://github.com/littlebizzy/slickstack/commit/9dbf28614252e6f346509f727824ba5c2224eaa7

Please let me know if that fixes it :)

jessuppi commented 1 year ago

Another update... here's how it looks now in ss-sync-staging script:

## copy wp-content files over (skips media uploads) ##
ss_rsync --max-size=5mb --exclude 'blacklist.txt' --exclude 'object-cache.php' --exclude mu-plugins --exclude temp --exclude upgrade --exclude uploads /var/www/html/wp-content/ /var/www/html/staging/wp-content

Ref: https://github.com/littlebizzy/slickstack/blob/master/bash/ss-sync-staging.txt

Likewise in ss-push-staging it now looks similar:

## copy wp-content files over (skips media uploads) ##
ss_rsync --max-size=5mb --exclude 'blacklist.txt' --exclude mu-plugins --exclude temp --exclude upgrade --exclude uploads /var/www/html/staging/wp-content/ /var/www/html/wp-content

Ref: https://github.com/littlebizzy/slickstack/blob/master/bash/ss-push-staging.txt

The object-cache.php file should never exist in staging, therefore it's not included for exclusion here...

Also, I've just added the --no-links flag to our ss_rsync bash aliases now, SlickStack only uses rsync for unpacking e.g. WordPress ZIP files or syncing/pushing staging sites, so it should be fine to use it here since we want to ignore the symlink pointing to the /uploads/ directory that exists in the staging site just to be sure.

Ref: https://github.com/littlebizzy/slickstack/commit/9a81d5d49fff39ccc4acc4aefced214286a36713

jessuppi commented 1 year ago

I ran some tests and the exclusion rules seem to be working correctly now... also some tweaks in ss-perms-wordpress-core to ensure that /uploads/ is a symlink for staging sites, etc.

Ref: https://github.com/littlebizzy/slickstack/blob/master/bash/ss-sync-staging.txt Ref: https://github.com/littlebizzy/slickstack/blob/master/bash/ss-perms-wordpress-core.txt

I'm going to close this for now, if any other syncing problems please open a new Issue or for any follow-up comments anyone is free to comment below. Thanks!