How to Back Up Your Websites" Files and Database

103 10
One of the most popular ways to back things up when you are hosted on a shared hosting server and using cPanel as the hosting control panel, is to use the inherent backup features of cPanel or simply file manager to package everything and then download the archive.
This article uses a whole different way to backup all your data and that is via SSH.
SSH stands for Secure Shell that enables a server's user to log into his or her account via a secure, exclusively connection to the server in a remote manner.
Via SSH, not only can you package everything that needs to be backed up but also download it via a encrypted channel that's impossible to be sniffed by hackers.
This is essential in ensuring the confidentiality integrity and of your data.
First you need to log in to the server using your username and password.
Once successfully authenticated, switch the current working directory to the one that contains all your website files by command 'cd', for example: cd /home/username/public_html Change 'username' to your own.
Chances are you have some websites that rely on MySQL database to store data.
We will need to export the data of those databases to SQL text files.
One by one, run command: mysqldump -u username -p db1 > db1.
sql Obviously, you have to change 'username' to your own corresponding database username and 'db1' is the name of the database to be exported.
You will be prompted to enter the password of the corresponding database user account.
You don't want to enter the password into the command line because that way the system keeping record of command history might reveal it to others.
Now that all SQL files are ready in the current directory, go ahead and package everything into an archive file with the file extension.
tar ready to be downloaded: tar -cvf backup.
tar * Which essentially packages everything in the current directory, namely /home/username/public_html including the SQL files we have just exported, to the file backup.
tar.
Depending on the size of the files and data to be backed up, you can use the -z switch of the 'tar' command to compress the archive file.
As it may consume large amount of server resources and computing time, it may not be a good idea on shared hosts because the server administrators may suspend the process once they see it making the server irresponsive.
Anyway, you have now backed up all the websites (script files and database) on the server.
Fire up a download agent to download the package backup.
tar to be kept safe somewhere on your local computer as well as a portal hard drive.
Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.