Hesk Automatic backup
Posted: Thu May 17, 2012 10:06 pm
I run Hesk on my hosting providers servers, so automatic backups were a little challenging. I found two solutions, both of which I have implemented.
For both of these methods you will need to be able to schedule a cron job. My provider uses CPanel which allows me to do this.
Method one - Backup to Server:
Method two - Email yourself the database.
.htaccess file to prevent any access from the browser. If you want to access from the browser, remove the .htaccess file
Thanks to Damien Oh at maketecheasier.com for these steps.
For both of these methods you will need to be able to schedule a cron job. My provider uses CPanel which allows me to do this.
Method one - Backup to Server:
- Open the your CPanel
Find the Advanced Tab
Click Cron Jobs
Code: Select all
mysqldump --opt -Q -u dbusername --password=dbpassword dbname | gzip > /path-to-store-the-backup-file/db_backup.sql.gz
- Replace dbusername with the database user
Replace dbpassword with the database user password
Replace dbname with the database that you are backing up
Replace the path-to-store-the-backup-file to the file path in your server where you want to save the backup
Method two - Email yourself the database.
- Download this PHP Script
Extract the zip file and open the backup.php with a text editor
Change the database detail to match your configurationIn the cron job section of the cPanel, enter the following commandCode: Select all
$dbhost = "localhost"; // usually localhost $dbuser = "dbuser"; //enter your database username here $dbpass = "dbpass"; //enter your database password here $dbname = "dbname"; // enter your database name here $sendto = "Send To <mail@mail.com>"; $sendfrom = "Send From <mail@mail.com>"; $sendsubject = "Daily Database Backup"; $bodyofemail = "Here is the daily backup of my database.";
Code: Select all
php -q /path-to-the-php-script-folder/backup.php
Thanks to Damien Oh at maketecheasier.com for these steps.