Webinoly is just the perfect tool for NGINX experts. Give it a try!
+3 votes
by Talented
I’m curious to know if anyone has tackled duplicating a site (either within same webinoly installation or to a separate VPS) to create a staging environment?

Basically I’m interested in creating a copy of domain.com to staging.domain.com in an automated/scalable way (ie don’t want to have to be manually editing config files, copying folders, mucking with SQL imports, etc).

Going to be digging into this soon and wanted to see if anyone else had laid any useful groundwork or had tips to tackle such a task. Thx!
by Talented

FWIW, here's what I'm doing in lieu of native duplication/staging functionality. YMMV:

Must ensure wpcli installed first: https://wp-cli.org/

1. Create new site

site staging.domain.com -wp -cache=on

2. Export database from current site and copy to new site

cd ~/www/domain.com/htdocs
wp db export
mv domain_com-2019-06-24-7a722fe.sql ~/www/staging.domain.com/htdocs/dbexport.sql

3. Import database

cd ~/www/staging.domain.com/htdocs
wp db import dbexport.sql
wp search-replace 'http://domain.com' 'http://staging.domain.com'

4. Copy files (themes/plugins/uploads)

cp -r ~/www/domain.com/htdocs/wp-content ~/www/staging.domain.com/htdocs

5. Visit new site!

(don't forget to point DNS records for staging.domain.com to your server)

2 Answers

+4 votes
by Talented
Best answer

I've been needing to migrate sites on an almost daily basis lately, so put this into a script to automate a bit. It doesn't have any error checking and I'm no bash expert (so I'm sure it's full of problems) but in case it helps anyone else before official support is released:


# usage:
# sh migrate.sh sourcedomain.com targetdomain.com

# Note:
# wpcli must be installed (https://wp-cli.org/)
# WP sites must already be created via webinoly


echo Migrating $SOURCE to $TARGET...

# path to Webinoly's www directory

cd "$WPPATH$TARGET/htdocs"

# migrate database
wp db export db_migrate.sql --allow-root --path=$WPPATH$SOURCE/htdocs
wp db import db_migrate.sql --allow-root
wp search-replace $SOURCE $TARGET --allow-root

# migrate files
cp -r $WPPATH$SOURCE/htdocs/wp-content $WPPATH$TARGET/htdocs

# clean up
rm db_migrate.sql

echo "Finished!"

by Expert
Thanks a lot Denny for sharing it here!
0 votes
by Expert

Hi Denny,

The good news is that this feature is in our roadmap to be a native option in Webinoly and it's scheduled to be released in v1.10.0 (December 2019).

For now, you can find a lot of plugins in WordPress that can handle it very well.


by Talented
Cool, looking forward to that as an official feature. Will it handle multisite? I didn't mention it because didn't want to complicate the question but that's what I'm specifically looking to do - so domain.com, sub.domain.com, would become staging.domain.com, sub.staging.domain.com.

Plugins generally aren't advanced enough to handle multisite/large installations that well, so was assuming I'd have to get my hands dirty with wpcli and/or some custom scripting to migrate it all properly into a usable staging site.
by Expert
I still don't know if in this first release it will have support for multisite, I'm still thinking and analyzing the best way to implement this feature.

Change the domain in an existing website or duplicate an existing website, both are so different use cases that can work to solve the "staging" feature.
by Talented
True. I'm going more for copying vs renaming myself. Posted my approach above. Thx for your input :D
by Expert
This feature has been currently released in v1.10.0.


Your feedback is important.
Welcome to the Community site for Webinoly.

Our Optimized LEMP Web Server is a powerful set of commands for doing just about anything you could wish.

With Webinoly you can set up your NGINX web server in just one step.

* * * * * * *

To report a bug, please create a new issue on GitHub or ask a question here with the bug tag.
Webinoly Support Paypal Donations

PayPal · GitHub Sponsors · Bitcoin

It is very important that any visitor to the site read the disclaimer, terms of use and privacy and legal statement before start browsing.