If you are also an owner of a website, then taking the backup of your website is the most important thing that you should do regularly. Majority of the web hosting providers will only offer weekly or daily backups, which is mainly for the purpose of a disaster recovery. But if you personally want to oversee your website’s backup, then it can be done by you by just using the backup function in the control panels of hostings like Plesk, cPanel and DirectAdmin. As a domain owner or webmaster, the one who is responsible for this task is only you.
Following criteria lies in the category of a good backup:
- You should backup your data as much as you can
- Web contents and databases are critical data. So they should be given higher priority. The temporary files can be excluded.
- An important thing is that DONOT save your backup inside the same server.
- You should be able to access and retrieve your backup, anywhere and anytime.
- if you have some concerns about the bandwidth or disk space, then your backups should be compressed.
- For every backup status that has been scheduled, you should get notified.
It is a good idea to have your own FTP server in order to store your backup remotely. But what are you going to do if your FTP server goes down? With limited access to the server, how are you going to automate the backup task? How are you going to make sure that it is always available?
The solution to all of the above questions is the cloud storage. It is now becoming one of the best ways to save files. There are some famous providers like Dropbox, Amazon S3, Box.net and iCloud. These providers are offering the storage facilities for free, of course with some limitations. So now, I am going to tell you that how can you backup your website into dropbox.
You can transfer anything from an FTP server to your Dropbox account, securely, with the help of Backup Box. What Backup Box actually does is that it integrates your FTP account with the providers of cloud storage. With limited features like immediate transfer schedule and monthly backup schedule, it is free to use.
This tool can be used in various ways. We can transfer the directly copied web directory using FTP, to Dropbox (uncompressed or compressed). Or we can also create a cPanel backup (compressed backup) and then use the FTP to fetch the backup to dropbox.
So if you are going to proceed with this article, then you are going to need following pieces of information:
- An FTP account that is mapped to directory of your web. Your hosting control panel can give it to you.
- An account of Dropbox
- An account of Backup Box
As you know that the database is also a very important part of a website, then you have to prepare the backup of your database and then place it in your web directory. You can use a task scheduler which is called a cron job, with a little help from mysqldump, only if you are running a Linux host. And if you are using cPanel, then it will be located in the following path : cPanel>Advanced>Cron Jobs.
We can use the following data for the sake of example:
Web directory path: /home/username/public_html cPanel username: mycpanel cPanel password: mypass123$
now you have to create a weekly cron job and enter the following command:
mysqldump --opt -Q -u mycpanel -p'mypass123$' --all-databases > /home/username/public_html/databases.sql
now this will create a backup file of SQL, and it will include all of your databases present under your cPanel account. Now you have to login to your Backup Box account. Then on the left panel, you have to login to your FTP account. You can login to it by clicking on the gear button. And on the panel, you have to login to your Dropbox account.
In the Transfer Options, you can choose Transfer public_html as folder. If you do this, then your whole public_html folder ( including all files ) will be transferred to your Dropbox account. Now by clicking on review, you can start the immediate transfer. Your public_html folder will be transferred to your Dropbox by doing this. Now once you have done this task, you can now create a monthly schedule to automate this backup task on monthly basis. To do this, you just have to click on Monthly>select Date and Time>Finalize and Run. If you want to use the weekly or daily backup, then you have to upgrade to the premium versions.
using the cPanel API, you can generate your own backup automatically. This is a great thing about cPanel. Now in this article, we are going to use PHP script, to run on schedule so that it can generate backup. And we need to create an FTP account mapped to a new backup folder, because the location of backup must be exclusively for Backup Box only.
Now you have to go to cPanel> FTP and then create an FTP account. The screen below will show you an example. And note that FTP directory should not be created under public_html as it is publicly accessible through a web browser.
We have to use cPanel API with PHP in order to trigger the process of backup. Now you have to download a file from this link ( [] )and the unzip it. You will see 2 files in there. xmlapi.php.inc and cpanel-backup.php. you have to change all the required information from cpanel-backup.php as below:
// Credentials for cPanel account $source_server_ip = ""; // Server IP or domain name eg: 184.108.40.206 or cpanel.domain.tld $cpanel_account = ""; // cPanel username $cpanel_password = ""; // cPanel password // Credentials for FTP to Backup Box $ftpacct = ""; // FTP account $ftppass = ""; // FTP password $email_notify = ; // Email address for backup notification
Now you have to save it and then upload both files into your public_html directory by using FTP. Now you can start to generate the backup by directly accessing the PHP file through a web browser. Usually it is [] .
Now if you want to automate the backup creation of cPanel, then you have to set up a weekly cron job into cPanel. Enter the following command:
php -q /home/username/public_html/cpanel-backup.php
now you have to login to Backup Box. Login to FTP account in the left panel (you have to use the FTP account of Backup Box), and then login to your Dropbox account in the right panel.
Now by clicking Review, you can start the immediate transfer. Your public_html folder will be transferred to Dropbox by this. And once it is done, then monthly schedules can also be created to automate this backup task on the monthly basis. You just have to go to the following path:
Monthly>select Date and Time>Finalize and Run.
You have to upgrade your subscription if you want to use the daily or weekly backup. So this is how you can automatically backup your website into your Dropbox account.
I hope this article helped you. Hope to see you soon. Thanks !!