Things To Remember Before Upgrading Production Server
Server security is the topmost priority for every system administrator. Besides having third-party security tools like Firewall, DDoS protection, etc., it is essential to keep every piece of code up-to-date on your production server.
When your application is in production, upgrading it is riskier. If Linux powers your server, Linux distributions keep releasing new versions now and then. Each major release contains bug fixes, security updates, and new tools.
Upgrading a production server without any preparation is a big mistake. An unprepared upgrade can cause permanent data loss, poor server performance, and customer loss. In this article, I will list some important steps to take before initiating a server upgrade.
Things to do before upgrading a production server
Just recently, I upgraded one of my client’s server, and it was a Ubuntu server. His e-commerce website receives a decent amount of traffic and has been around for almost a year now.
I decided to upgrade his server from Ubuntu 18.04 to 20.04 LTS. The actual upgrade took about 30 minutes, but the preparation took longer. As a result, the upgrade was smooth without any downtime.
Prepare full backup
Before upgrading, make sure your website is fully backed up in the cloud or locally. Backing up just the website or the entire server should be a daily task. Recently, I listed some of the greatest backup plugins for WordPress. If WordPress powers your website, read the article best backup plugins for WordPress.
If you are using any other CMS, create a backup of the application. If you are using cPanel based web hosting, there should be an option to create a full backup of the entire server. Creating full backup from cPanel is the easiest way.
If you use any of the cPanels that I have covered in my cPanel series, they all have options to create a full backup. All of these Linux cPanles are free and open source. Just let me know if you have any trouble with any one of the cPanels I have reviewed, I will help you out.
Once you have a complete backup of your server, you can proceed to the next step.
Software compatibility
The newer Linux distribution may have removed or replaced tools that your website or CMS uses. Mostly, popular CMS like WordPress will not have any issues. If you have a custom CMS that might be using a certain library, make sure it still exists in the newer version of the operating system.
Setup temporary server
The entire purpose of this article is to upgrade a live server without any downtime. While the server is upgrading, it may restart multiple times; hence the website will not open during the restart. The best way to avoid it is to create a separate server and restore your website to the new server.
You can restore the backup on the new server and point the domain name to the new server temporarily. During the upgrade, visitors will visit the temporary website instead of the main.
We have already covered how to migrate a WordPress website from one server to another in detail.
Set up load balancer
The load balancer is the best way to manage traffic on your website and make sure every visitor accesses the site no matter what’s happening on the server. Load balancer may cost a little but is worth using if you receive a large amount of traffic on your website.
We can use premium load balancer services during the upgrade and redirect all the traffic to our temporary server without changing domain settings.
If you use the Cloudflare firewall, you are in luck. Cloudflare provides load balancing at the cost of $5/month. It’s cheap, and you can cancel it anytime.
Enter the IP address of the main website server and temporary server in the load balancer. After successfully connecting servers with the load balancer, it will redirect the visitors to the functioning website.
If your main server does not respond during the update, the load balancer will serve visitors a temporary website. After the server has been upgraded, we can remove the temporary server.
Start server upgrade when the least traffic is on site
Even though the above points will prevent your services from going down, it is still better to start the upgrade when you receive the least traffic on site. You can use Google Analytics or any other website analytics service you’ve connected with your website.
Conclusion
Once the server has been upgraded, you can point the domain name to the main server and remove the temporary server after a few hours. If you did not change the domain settings and used a load balancer instead, you can delete the temporary server and remove the temporary server’s IP address from the load balancer.
A failed upgrade can cause a real problem for your services. It is crucial to plan server upgrades and prevent losing any data during the upgrade.