Hello, this subject keeps coming up. It is how do I work on sites without breaking the live thing. Then taking the changes and pushing them into production.
This is the method that I use. There are hundreds of ways to do this. This is just my preferred.
First step is to use this plugin by ServMask. It is rock solid. The free version supports sites up to 500MB in size. That might not sound like a lot but it is enough in most cases.
Install and activate from the wordpress plugin repository.
Once installed click "backup location" = "local". This will archive every single thing that is in the site. It will wrap it up into a nice file with a .wpress file extension
There is hope. You do not need the pro version. If you want to support the company and save some time then by all means show the dev's some love.
If you want to go another route that is more time consuming then use the native import/export function of WordPress.
This method is not preferred because if there is an issue then you have no tidy backup file to lean on.
However, I have done it multiple times with no problem
Go to Bitnami wordpress stack -> virtual machine. Download the virtual disk file
Download VirtualBox. It is available for Linux, mac, and windows
Import the virtual disk into a new VM
Make sure to change the networking to "bridged" also if needed change the disk space size.
If you used all-in-one then the plugin will be preinstalled on the new stack. All you need to do is select the backup and let it do its thing.
If you used the wordpress native import/export then follow the above steps.
After all is complete the sandbox might not load. That is where the next step comes in
The "hosts" file on your computer enables hard DNS overrides. You can tell your computer to, when resolving a domain, resolve here instead of live dns records.
We do this with the sandbox because it prevents having to change the sandbox wordpress install domain. Saving time and ensuring a smooth transition back to the live server.
You can find the sandbox IP by typing "ip a" in the console or looking at dhcp leases on your router.
Easy enough right? there are some corks. Mostly that if it is an Elementor site with pro Elementor the license will not be active. There is no way to activate it except changing the WordPress install domain to something.dev
That is very annoying. For most plugins they will behave normally. I have never found one as tight fisted as Elementor.
Otherwise. If you need to visit the live site just change back the hosts file to not manually resolve the domain
Now the scary part. Overriding a live site. This can be nerve racking but just remember that you have a copy of the original files on the server.
If you used all-in-one then the original .wpress file will still be on the server. If you used the alternative method then you have the files downloaded.
Well when you are ready, take a backup of the staging site and reupload it to the live site. If you used the native method then you will also need to upload images to the live server separately. There is no automatic method for the live site to grab images from the sandbox.
Everyone has an opinion on how to do this best. Some use all online sandbox sites. This way is free. Some hosts have sandbox services, some do not.
Whatever the case the above methods will work every time. Regardless of hosts.
Any questions leave them bellow.
Hello, today I had a task and was unable to find a complete guide for it. So here you go.
This is a simple task. You have two sites on the same database server using different databases. You want to merge them into the same database.
I needed to do this so I could share user tables between sites. Without using Multisite.
We need to let the MySql user of site1 be able to make changes on site2's database.
mysql> GRANT ALL PRIVILEGES ON site2's-db.* TO 'site1s-username'@'localhost';
mysql> FLUSH PRIVILEGES;
Now we change the prefix of site1 so that there is no conflicts when we move over it's tables to site2's database.
Now we must correct all the inner-table prefixe's.
Come over to here in php-my-admin (in the database of the site you just appended.)
Run the following queries:
SELECT * FROM `NEW-PREFIX-GOES-HERE_options` WHERE `option_name` LIKE '%wp_%'
That will give you all the table entrys that still have the old prefix. You need to manually change every entry displayed to the new prefix
Do the same with the results of this query:
SELECT * FROM `NEW-PREFIX-GOES-HERE_usermeta` WHERE `meta_key` LIKE `%wp_%`
Now time to merge the two sites databases together into one.
Make a folder somewhere where you can save the .sql export to. You will only need it for a second.
Now time to export site1's database to it
You need to be logged in as root for this.
sudo -i mysqldump -u root -p SITE1'S-DATABASE-NAME > /YOUR-CREATED-DIRECTORY/ANY-NAME.sql password: MYSQL-ROOT-PASSWORD
Now a copy of site1's database is in whatever directory you put it in.
Now time to import it to site2's database (will still need to be logged in as root.)
mysql -u root -p SITE2'S-DATABASE < /YOUR-CREATED-DIRECTORY/SITE1-BACKUP-NAME.sql password: MYSQL-ROOT-PASSWORD
Now site1's database is merged with site2's
Now you have to change site1's wp-config.php to use site2's database.
You have merged two WordPress sites into a single database.
Any questions feel free to comment below.