Did you know that RunCloud now does instant backups? We introduced this little feature under the radar, but thought it was about time we highlighted the possibilities because… RunCloud Instant Backups = Easy Site Cloning!
In a previous article we showed you how to easily clone a RunCloud deployed WordPress staging site from a production site using the RunCloud integrated backups feature. Whilst this showed just how easy it is to clone a WordPress site, the real drawback was the inability to make an instant backup from which to replicate your cloned site. Previously RunCloud needed a minimum of 2 hours to make a backup. Not exactly an instant solution and a roadblock that might make many look for alternative solutions for this common task.
Well no more! RunCloud backups now offer an immediate backup solution. To use this incredibly handy feature all you need to do is proceed to backups in your RunCloud control panel and go through the usual process of setting up a RunCloud Backup:
Instant Backups make cloning easy
First click create on the Web application you wish to backup:
Now select the Web Application you want to back up, you will need to also select the backup timing and retention. Although if you are only interested in using the backup to create a clone you can set these to anything.
The most important thing is to make sure you have selected Full Backup from Backup Type before clicking Create, and then clicking Yes I’m Sure in the popup confirmation modal.
Once you have clicked to confirm the backup will be configured and you will be taken to a summary panel for this backup with….. drumroll….. yup, you guessed it an option to make an immediate backup.
In the top right corner of the Backup panel there is now a lovely big green Backup Now button! Click this button, and then click the big blue Backup Now button in the popup confirmation box and RunCloud will now make an immediate backup of your web applications directories and files.
Remember though, to make a clone of any site you will also need to make a backup of your site’s database, but that isn’t a problem because you can also now make immediate database backups.
If you want to make an immediate clone of a WordPress site it is now possible by just following our previous guide, and using WPCLI search-replace commands to adjust the database for the clone domain.
Of course, RunCloud is a VPS management platform and PHP web application deployment solution that works across the entire gamut of the PHP development world. Therefore we would be remiss if we didn’t discuss solutions for other PHP platforms. Having said that, there are so many other PHP platforms and complete custom PHP web applications hosted on servers managed by RunCloud so there is no simple, one answer fits all, solution for updating the database.
Using SQL Queries
One basic answer involves running a SQL query on your MariaDB through whichever MySQL client you use to manage your database (PHPMA, Adminer, Sequel Pro, HeidiQL or others), and the specific command will depend on how you have set your tables up.
Depending on the design of your web application database you might only need to replace the URL in one table, and so you could use something like:
UPDATE table_name_here SET column_name_here = REPLACE(column_name_here, 'http://domain', 'https://newdomain')
Using a text editor
But sometimes you might need to replace all occurrences of a string, such as the original site domain, throughout the entire database across multiple tables. In which case you could write a much more complicated SQL query. Many people prefer this method, but I personally don’t really like SQL, so in such a case I would opt to export the entire database.
And then open the exported database in my favourite text editor and use the editors find and replace to replace every instance of the original domain string with the clone site’s domain in every table throughout the database.
One you have replaced all the domain strings and saved the SQL file, you can now import it back into your Web Application database.
So there you go, an incredibly useful addition to the RunCloud backup feature that makes cloning sites even easier than before. Let me know how you prefer to clone sites in the comments below.