The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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:
    1
    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:
    1
    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:
    6
    Location:
    Saitama-ken,japan
    Or

    0 0 * * * mysqldump --opt (DB_NAME) -u (DB_USERNAME) -p(DB_PASSWORD) > DB_NAME-$(date +%m%d%Y).sql
     
  4. jalal

    jalal Active Member

    Joined:
    Jun 15, 2005
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    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:
    6
    Location:
    Saitama-ken,japan
    So, yes.;)
     
Loading...

Share This Page