SixServe - Free No Ads cPanel Web Hosting: How to Schedule a Database Backup Using Cron Jobs. - SixServe - Free No Ads cPanel Web Hosting

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to Schedule a Database Backup Using Cron Jobs. This tutorial is only for SixServe and Squidix Customers.

#1
User is offline   FlightPilot 

  • SixServe Team (Support)
  • Group: Staff
  • Posts: 2,554
  • Joined: 28-December 11
  • LocationSomewhere in the Sky.
Welcome to SixServe Hosting
Tutorial : How to Shedule or make a backup for your database's using Cron Jobs in cPanel.
Well hello there, Say you want to backup your website database or maybe the latest backing up of your WordPress database in this matter. Lets work with a basic tutorial with backing up your WordPress database in this tutorial. We are aware that there are plenty of plugins around that can get the job done. Some of them backup only your database while others backup the whole WP directory. If you have used WordPress long enough, you will realize that these plugins are not reliable. They will work one day and fail another day, for thousand and one reasons. It could be that they are not compatible with the new WordPress version that you have upgraded to, or that they are conflicting with a newly activated plugin. As in my case, it could also because your database is getting too big for them to handle.Whatever the reasons, rather than relying on plugins, a better alternative is to use a cron job in your server and schedule it to backup your database everyday. This can even work in with any website or script. Just make sure you read in everything carefully. Keep it in mind : The only requirement is that you are using a Linux server to host your files and a control panel like cPanel which SixServe provides you with . Lets Begin Shall we ? Okay, 1. Login to your web host control panel (cPanel @ yourdomain.com/cpanel). If you are using cPanel, look for a Cron Job icon. Posted Image

2. You can set the time and frequency to backup the database. Under the command field, copy and paste the following command:


mysqldump --opt -Q -u dbusername --password=dbpassword dbname | gzip > /path-to-store-the-backup-file/db_backup.sql.gz[/size][size=2]


3.

  • 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.

Note: In some server's, you might need to put a pair of single quote around the dbpassword for it to work. For example:

mysqldump --opt -Q -u dbusername --password='dbpassword' dbname | gzip > /path-to-store-the-backup-file/db_backup.sql.gz[/size][size=2]


Now, E-mail yourself the Database -Storing the database on your server could take up plenty of storage space. One way you can do is to email the backup file to yourself.
  • Download this php script.
  • Extract the zip file and open the backup.php with a text editor.
  • Change the database detail:

$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 <sendto@email.com>"; //the email address to send the database to
$sendfrom = "Send From <sendfrom@email.com>";
$sendsubject = "Daily Database Backup"; //the subject of the email$bodyofemail = "Here is the daily backup of my database.";




  • Save the file. Upload the whole folder to your server. Note: The folder includes a .htaccess file to prevent any access from the browser. If you want to access from the browser, remove the .htaccess file.
  • In the cron job section of the cPanel, enter the following command:

php -q /path-to-the-php-script-folder/backup.php



Thats it , now you'r done. Enjoy your day and hosting with SixServe/Squidix Hosting.

Copyright SixServe Tutorials.




FlightPilot
Si6 Staff
Personal Message (PM) Staff/Admin is not the right way to seek help. Just post it in the Forum and our crew will take care of it.

Posted Image Go Unlimited ! Premium Hosting with Unlimited domains and 99.9% up-time for Just USD $4.99. Grab it!
0

#2
User is offline   Dave 

  • SixServe Lead Technician
  • Group: Staff
  • Posts: 2,529
  • Joined: 19-September 11
  • LocationMaine
Nice tutorial.
Best Regards,
Dave
SixServe Support Team Member

Posted Image
Get a Free Laptop! (PoliticalBB - Politics Debate Forum)!

DoubtFireBlog - Don't Doubt the Fire of Thought Express your thoughts, become a blogger, and much more with DoubtFire Blog!
0

#3
User is offline   niko 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 6
  • Joined: 23-April 12
I thought Cron Jobs is complicated but based on this Tutorial, it is very easy to use and useful for backup
0

#4
User is offline   Ronnel Martinez 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 58
  • Joined: 12-February 12
  • LocationPhilippines
Great :rolleyes:
Posted Image

Posted Image Facebook | Posted Image Twitter
Email: ronnel.nelouszxc@yahoo.com

"Think before you click"
0

#5
User is offline   Roxane 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 135
  • Joined: 06-April 12
Thank :) GREAT
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users

Squidix Web Hosting