cPanel: Automatic MySQL Backups for the Novice

By DMB · Dec 31, 2005 ·
  1. DMB
    cPanel: Automatic MySQL Backups for the Novice

    The ease of which users can create a message board or online community is becoming easier every day. With the help of Fantastico, which is provided with most hosts, a user can create a message board in three clicks. The problem with this become apparent when the word "backup" comes into play.

    Those who are not tech savvy tend to believe that their hosting company will take care of backing up their information. While this may be true, the hosts explicitly state they can not guarantee the quality, or lack of corruption, of said backups.

    For those with cPanel, I have an easy + automatic solution.

    Navigate to "Cron Jobs" and choose the "Advanced (Unix Style)" layout.

    You will be given the following options:

    Minute: 0
    Hour: 3 // This represents 3AM, which is usually an inactive time
    Day: * // Means the script is run every day of the week
    Month: * // Means the script is run every month of the year
    Weekday: 0 // Means the script is run every sunday
    Command: mysqldump --opt -Q -u dbusername --password=dbpassword dbname > /pathto/backups/sunday.sql

    In the command prompt, you will need to replace the red variables that correspond to your information. Remember, if you are on shared hosting, your dbname and dbusername probably have a prefix.

    Also note that it is asking for the backup path, not the backup URL.

    After doing the first script repeat it six times but change the weekday from 0 to 1 (then 1 to 2, until you reach 6) and the filename from sunday to monday (then monday to tuesday, until you reach saturday).

    After you have completed the above step, you are finished!!!

    With this method, you are backing up everyday, BUT you have copies from the past seven days instead of rewriting the same copy everyday. This is advantageous because you may want to restore to a certain point or your only backup may have been corrupted.


    Share This Article

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.