So I finally decided to start the backing up and migration work from the cloud server.
It’s been quite some time since the website was set up, more than 4 years. There were also many changes to the settings compared with the very initial ones and because I was lazy to keep the notes up to date, I was lost on the current configurations, including the database the website is using, the connection account and password, and also some other manual configurations, etc. Literally, I am facing a website I have not much knowledge of how it’s set up. Ok, then, let’s refresh the memories by checking the settings one by one, and also updating the notes or even create a more formal documentation for future reference. Fortunately, I still have the admin credentials of the cloud server, both the local host and MySQL, which makes things a little bit easier.
First, let’s see the website configuration from wp-config.php
file under the website root directory by sudo cat /var/www/site/wp-config.php
Ok, now there are four main tasks
- Back up the database used by the site and also the site files;
- Copy the database and site file backups to the on-premise server;
- Install necessary software and Create a new database on the on-premise server and import the data to the new database;
- Configure the site to use the new database;
Task 1
- Archive the site files using tar
tar -czvf wordpress_backup.tar.gz /var/www/tunerli.com
- Back up the database
mysqldump -u root -p database > wpdata_backup_20241228.sql
Task 2
- I have limited the SSH access to the cloud server only from my home workstation, so I will need to copy the backups from the cloud server to my home workstation and then copy them to the on-premise server.
- Copy the backups from the cloud server to my workstation
scp user@cloudserver:/home/user/wordpress_backup.tar.gz .
scp user@cloudserver:/home/user/wpdata_backup_20241228.sql .
- Now copy them to the new server
scp wordpress_backup.tar.gz user@localserver:/home/user/
scp wpdata_backup_20241228.sql user@localserver:/home/user/
Task 3
- Install the necessary software on the new server
sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql
- Put the site files to the corresponding place
sudo tar -xzvf /home/user/wordpress_backup.tar.gz -C /var/www/
- Create a new database and user for the site connection
- CREATE DATABASE NEWDATABASE;
- CREATE USER ‘NEWUSER’@’localhost’ IDENTIFIED BY ‘PASSWORD’;
- GRANT ALL PRIVILEGES ON NEWDATABASE.* TO ‘NEWUSER’@’localhost’;
- FLUSH PRIVILEGES;
- EXIT;
- Import the data from the backup to the new database
- mysql -u NEWUSER -p NEWDATABASE < /home/user/wpdata_backup_20241228.sql
Task 4
- Update the wp-config.php file with the new database and user credentials
- create a new conf file for this new site under /etc/apache2/sites-available/
sudo nano /etc/apache2/sites-available/site.conf
- Check the syntax error
sudo apache2ctl configtest
- Enable the new site and rewrite module
sudo a2ensite site.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
- Disable the default site
sudo a2dissite 000-default.conf
Now it’s time to confirm! As I haven’t figured out the DDNS solution/vendor, I can only test with the IP information for now and I have done that in the conf file for the site. So now access it from IP
Bingo! Works. Ok, now I am going to update the documentation for this part before I start working on the next step of DDNS setup.