WEB DEVELOPMENT: Show
A complete solution with step-by-step instructionsImage by Geran de KlerkSummary:The main benefit of reading this article is that you will learn how to use mysqldump to backup and restore your database. This includes performing a one-time backup, creating a remote backup service, transferring the backup, and restoring your database from the backup. This will protect your database in the event of hardware or software failure, data corruption, and human-caused events, such as malicious attacks or deletion of data. However, this cannot protect your database from breaches that are caused by improper access privileges, weak passwords, and unencrypted data. We will use Linode as our cloud service provider because their products are easy to use, affordable, scalable, and their customer service is outstanding. We will use Nginx as our web server because their product is free, handles high website traffic, and powers 60% of the top 100k websites in the world. Promotion: This referral link provides a $100 credit for Linode # How to Put a High Performance Website on the Internet: Create the Virtual Machine:The Virtual Machine is an emulated computer system with its own CPU, memory, storage, and network interface that exists on the physical hardware of our cloud service provider. This allows us to install our web server, host our website, and upgrade our hardware as needed for a small monthly cost. In this section, we will create the virtual machine that will contain our website using the least expensive monthly plan available. # create virtual machine Install the Mysqldump Utility:The Mysqldump utility is program that backs up our MySQL database. This allows us to generate a MySQL file that contains the SQL statements that we need to recreate the structure and data in our database. In this section, we will install the Mysqldump utility by installing the MySQL-Client package. # open console as root user on linode Enable the Uncomplicated Firewall:The Uncomplicated Firewall is a program that protects your computer from attacks by blocking the incoming and outgoing network traffic based on IP address and port information. This allows us to restrict our network traffic to the IP addresses and ports that we permit in our firewall rules. In this section, we will block all incoming network traffic by executing a command. # enable firewall Create the User Account:The User Account is an entity that can access files and perform commands. It makes it harder for attackers to hack our web server by requiring them to crack our username before they can even try to figure out our password. In this section, we will create a user account with administrative privileges. # change "placeholder" to unique username Disable the Root Login:The Root User is a user account with unlimited access to the entire system that comes preinstalled with every Linux-based operating system. This provides attackers with half of the information they need to hack our web server. In this section, we will prevent the root user from accessing our virtual machine by changing the setting in our SSH configuration file. # disable root login Disable the Password Authentication:The Password is an authentication method that becomes a threat when the password is too weak or reused with many different accounts. This allows attackers to potentially crack the password through trial and error. In this section, we will prevent users from accessing our virtual machine using password authentication by changing the setting in our SSH configuration. # disable password authentication Create the MySQL User:The MySQL User is a user account that can potentially destroy our entire database. This usually occurs when a new database administrator grants the “all privileges” option to their MySQL users out of convenience. In this section, we will prevent this by creating our MySQL user with the absolute minimum amount of privileges that are required to backup our database. # open console as root user on linode Create the Backup Schedule:The Crontab is a program that automatically executes a set of commands at specific dates and times. This allows us to create a routine backup of our database that reoccurs at the scheduled time interval. In this section, we will backup our database one-time every day by creating a crontab file. # get ip address of "database" linode Create the Backup File:The Backup is a copy of our database that protects us from data loss. This allows us to restore our data in the event of hardware or software failure, data corruption, and human-caused events, such as malicious attacks or deletion of data. In this section, we will implement this by creating a web server, preparing the web server, and creating a routine backup service. # create backup file one-time Open the SSH Port:The SSH Port is the port that the SSH Protocol uses to establish the secure connection between our linodes. This port is closed by our firewall on our “database” linode. In this section, we will open our SSH port by adding a firewall rule to our firewall, and by enabling the password authentication. # get ip address of "database" linode Transfer the Backup File:The “database” linode doesn’t allow remote access from the root user. This makes it much harder for attackers to access our database by requiring them to have hacked into our cloud service provider’s data center beforehand. However, this prevents us from restoring our database from our “database-backup” linode remotely because the mysqldump utility requires root access. In this section, we will establish a secure connection between our linodes, disable the password authentication, and transfer our backup file. # open console as non-root user on linode Restore the Database with the Backup File:The MySQL program has the ability to replicate the structure and data in our database from our backup file. This allows us to recreate our database from scratch or overwrite our existing corrupted database. In this section, we will delete our existing database, recreate it, and remove our backup file. # open console as non-root user on "database" linode |