Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

cron job - command to backup a database ?

Discussion in 'General Discussion' started by king007, Aug 15, 2006.

  1. king007

    king007 Registered

    Joined:
    Aug 15, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    151
    What is the cron command to backup a mysql database, daily either by emailing the database to me or backing it up on the webserver ?
     
  2. trich

    trich Member

    Joined:
    Aug 8, 2006
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    151
    Check out mysqldump. Use something like:

    mysqldump --opt (DB_NAME) -u (DB_USERNAME) -p(DB_PASSWORD) > /path/to/dbbackup.sql

    Notice no space after -p.
     
  3. Shinichi Kato

    Shinichi Kato Well-Known Member

    Joined:
    Mar 7, 2005
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    156
    Location:
    Saitama-ken,japan
    Or

    0 0 * * * mysqldump --opt (DB_NAME) -u (DB_USERNAME) -p(DB_PASSWORD) > DB_NAME-$(date +%m%d%Y).sql
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. jalal

    jalal Active Member

    Joined:
    Jun 15, 2005
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    156
    It is better to put in the path for the binary, so better would be:

    Code:
    0 0 * * * /usr/bin/mysqldump --opt (DB_NAME) -u (DB_USERNAME) -p(DB_PASSWORD) > DB_NAME-$(date +%m%d%Y).sql
    
     
  5. Shinichi Kato

    Shinichi Kato Well-Known Member

    Joined:
    Mar 7, 2005
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    156
    Location:
    Saitama-ken,japan
    So, yes.;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  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.
    Dismiss Notice