Staging - add ability to ignore certain files
Thanks for adding the new staging feature, this is great!
During my testing I discovered that my staging .htaccess file was pushed to live and the result was a 500 error on live. I need to use a slightly different .htaccess file on staging, because I force the www version on live. I couldn't access staging with this rule. So the differences in .htaccess rules caused the error.
It would great if you could add a way to ignore certain files, similar to gitignore.
We have added the ability to ignore certain files/folders during push/pull operations https://support.cloudways.com/en/articles/5124886-how-to-create-a-staging-environment
It would be great to have the option to select exactly what is or isn't needed when cloning a site to setup staging. For example I run a separate server for staging and my main site is now too large to clone over so if I were able to clone it without media files it would be great. Also Every time I clone a site for staging my first task is to remove all WooCommerce orders and customers so it would make life much better to skip that step.
We would use this to increase the speed of staging-site-creation as well as save ~100 GB of server space — we don't really need to copy our large collection of MP3s every time we create a staging site.
If it helps others, you may be able to use RewriteCond to say things like, "only redirect to www IF the current site is the live site". That would let you use the same .htaccess file, with different commands for both staging and live sites.
There is suggestions dating back to 2016,17,18 and 19 to be able to do this but still no working solution?
You are able to do this at other platforms such as at Heroku, AWS, Azure and more.
Else the staging functionality would be pretty useless or at least an hassle to deal with if you need to reset your .env every time before you push your code while using a framework.
I do under stand that the servers are hosted at other services and could be a bit tricky to set env if there apis dosen't support it.But at least add it for those that dose...
Or an other approach would be to add an ignore functionality for specific files such as .env when pushing data.
The .env file and its vars should NEVER be track by git and should ALWAYS be ignored do to it cant include secrets or in laravel/lumens case even passwords.
I was advised by your support to create a php script that calls Cloudways api to trigger the staging push then overwrite my .env after this i done.
This works but still this would not be a valid solution in my opinion do the secrets and passwords has to be hard coded and/or tracked.. Also if you have many applications hosted you also need to create this script for every application you create.
Zishan Javaid commented
There should be a field to exclude certain folders while pulling data from live to staging site.
Owen Keary commented
this isnt a hard feature to have and is critial why havent we got it yet!
Its a critically required feature. I have separate config files for live and staging.
After pushing from staging to live, my live application starts working the way which isn't expected.
Why not just add a file tree that we can choose exactly what we want to push and pull back and forth?
Fabio Fava commented
So, some files should be left "as-is" for the already commented reasons:
- wp-config.php (salt keys & other tweaks we may do) and .htaccess (same reason).
- All folders having "cache" on the name should not be pushed/pulled (serialization).
The Staging as is on November 6 2018 isn't yet perfect. My main site is in Brazilian Portuguese, and when I select this language on the WordPress Settings, some custom translations get crazy as you can see on my ticket below:
Anyway I think we are very close of having a nerly-perfect Staging System.
Carl Nasal commented
Similiar to Steve's comment, I found that wp-config.php gets copied when you push or pull. I'm using Redis with the "WP_CACHE_KEY_SALT" defined in wp-config.php, and that key is being overwritten when pushing or pulling, which causes the site to use the wrong Redis cache key, which introduces all kinds of problems.
It would be nice if we could control what files to exclude, but even if not, there may be a few common files that should always be excluded like .htaccess and wp-config.php since those are designed to be specific for a given instance.