Page 1 of 1

Cloning website, making staging copy (v-clone-website)

Posted: Tue Jun 08, 2021 2:44 pm
by myVesta
We have an script for website cloning: v-clone-website

Let's say you have yourdomain.com and you want to make stage.yourdomain.com in one command.
In your SSH run:

Code: Select all

sudo /usr/local/vesta/bin/v-clone-website yourdomain.com stage.yourdomain.com
Our script will show you what will be copied, what database will be created, what URL will be replaced, just press enter to confirm it.
And that's all, the script will clone your site.
WordPress, Joomla and Open-Cart will be detected automatically, no need to enter DB credentials manually.

Want to copy stage back to production?
In your SSH run:

Code: Select all

sudo /usr/local/vesta/bin/v-clone-website stage.yourdomain.com yourdomain.com
Script will do the rest.

For custom CMS

In case that you want to clone custom CMS which doesn't store files outside of /public_html folder and there is only one config file, run:

Code: Select all

/usr/local/vesta/bin/v-clone-website domain1.com domain2.com --CMS_TYPE='other' --CONFIG_FILE='config.php' --FROM_DATABASE_NAME='myuser_db' --FROM_DATABASE_USERNAME='myuser_db' --FROM_DATABASE_PASSWORD='mysqlpass1234'
Another scenario would be if you want to clone CMS which does store files outside of /public_html folder and have multiple config files, then you will run this command:

Code: Select all

/usr/local/vesta/bin/v-clone-website domain1.com domain2.com --CMS_TYPE='other' --SITE_SUBFOLDER='..' --SEARCH_FOR_CONFIGS_DATABASE_NAME=1 --CONFIG_FILE='public_html/config.php' --FROM_DATABASE_NAME='myuser_db' --FROM_DATABASE_USERNAME='myuser_db' --FROM_DATABASE_PASSWORD='mysqlpass1234'
Commands explanation:

--CMS_TYPE='other' If CMS is different from WordPress, Joomla or Open-Cart
--SITE_SUBFOLDER='..' If there are files outside of /public_html folder, use this command to navigate up one directory level. Or you can use this command to navigate directly to subfolder where all files are stored
--CONFIG_FILE='config.php' If there are files outside of /public_html folder, you have to set path to config file, '/public_html/config.php'
--SEARCH_FOR_CONFIGS_DATABASE_NAME=1 Used in case that CMS has multiple config files

Keep in mind that you have to manually read database name/username/password from config file and insert those information in script.

See source code of the script for all available parameters: v-clone-website

Re: Cloning website, making staging copy (v-clone-website)

Posted: Wed Jul 28, 2021 11:50 am
by wpinsites
Thanks for this excellent tool!

I have just used it for the first time to create a staged site to test updates, and now want to copy the staged site back to the production site. I noted, however, that when it displayed the summary of the information to be used to complete the clone, the DATABASE_SUFFIX was set to _migrated, as it was when creating the clone. Is this correct? Should I be using an override so that it doesn't change the structure of the database on the original site?

Re: Cloning website, making staging copy (v-clone-website)

Posted: Wed Jul 28, 2021 8:32 pm
by myVesta

Code: Select all

--DATABASE_SUFIX=... (default is '_migrated')
so you can override it with this parameter.
If you are cloning site to different account, then you can set it to empty string:

Code: Select all

--DATABASE_SUFIX=""

Re: Cloning website, making staging copy (v-clone-website)

Posted: Thu Jul 29, 2021 12:36 am
by wpinsites
So if I'm copying the cloned (staged) site back to the original, should I override this parameter and set it blank so that I don't end up with the "_migrated" suffix on the original site?

Re: Cloning website, making staging copy (v-clone-website)

Posted: Thu Jul 29, 2021 1:39 am
by myVesta
wpinsites wrote:
Thu Jul 29, 2021 12:36 am
So if I'm copying the cloned (staged) site back to the original, should I override this parameter and set it blank so that I don't end up with the "_migrated" suffix on the original site?
If you clone stage back to original, this script will figure out that it's stage (thanks to '_migrated' sufix) and will copy database directly to original database.

So, let's say we have database test_wp on test.com domain.

If you clone it first time:
v-clone-website test.com stage.test.com
you will get database test_wp_migrated

but...
if you want to copy the stage back to the original:
v-clone-website stage.test.com test.com
then test_wp_migrated will be copied back to test_wp

So, thanks to '_migrated' sufix, script will figure out that you want to copy stage back to original.

Re: Cloning website, making staging copy (v-clone-website)

Posted: Thu Jul 29, 2021 3:27 am
by wpinsites
Brilliant. You're awesome! Thanks! :D

I love this script. It is so quick. :!:

Any plans to add this (and possibly the script to install WordPress) to the web interface, possibly in the domain options menu when you hover a domain? :idea: