E-Commerce Sites Automated Backups

As many of the developers host their e-commerce sites locally or on cloud, they are required to take the backup of their applications on some remote location so that they may recover their data if any type of  failure occur and can make their websites available to everyone soon after the downtime. Although many of the e-commerce sites frameworks such as magento, joomla etc provide backup functionality at their own but it requires you to login to the console,navigate to the backup page, click the backup button, wait for the backup to finish and then download the backup. Moreover, you might not be familiar enough with this backup procedure as it may differ from framework to framework.

What if we provide you a better way to automate the complete backup of your e-commerce website on daily basis and store them on some remote location. This requirement includes a simple bash script, FTP connection to destination location where you want to store your backup and setting up cron jobs in order to automate them. Here we go !

STEP1-Login Without Password : Since we want to completely automate the process using cron job, it requires that the backup script won’t ask for password at run time to store the backup at destination location. For this, we must be able to access the destination location from our local system without password. We have multiple ways to do so, the first way is to login using pem files and the other way is to place your public key into destination’s authorized keys.Here, we will describe the latter one.

Generate public key :

The generated public key is stored in /home/users/username/.ssh/id_rsa.pub.Place your public key into destination’s authorized_keys :

This command will prompt you for the password if you are trying to connect for the very first time, and then it will place your public key into destination’s authorized keys. Now, everytime you want to ssh/scp the destination location from your local system, it won’t prompt you for password since the destination location now recongnizes your public key.

STEP2-Write The Backup Script :

Create a simple bash script named mysite_backup.sh inside your home directory i.e. /home/username/mysite_backup.sh and paste the following content :-

STEP3-Setup Cron : The final step is to run this script on regular basis which requires to setup a cron job. Run the following command :-

Suppose you want to run this script everyday at 9 pm (this may change according to your requirement), add the following in the last line :-

0  21   *  *  *  $pathtoscript/cpanel_backup.sh

 

IN CASE OF ANY QUERY, PLEASE CONTACT US

 

 

Category(s) Uncategorized
. . .

Comment

Add Your Comment

Be the first to comment.

css.php