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 to back up MySQL database

Discussion in 'General Discussion' started by BMR777, Jan 30, 2010.

  1. BMR777

    BMR777 Member

    Joined:
    Nov 26, 2008
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    51
    Hello,

    I have the following command that I run via SSH and I want to run instead as a cron job:

    Code:
    mysqldump  --opt --single-transaction -uusername -ppassword database > /home/username/backups/file.sql
    This command backs up my MySQL database file. My question is, how can I make this a cron that runs without removing the contents of file.sql? If I run this once a week will it just overwrite the file.sql file or not execute because the file already exists, unless I delete it?

    Ideally I would like to have it save the file in such a way that there are multiple dump files present until I delete them, either like file1.sql, file2.sql or file_todaysdate.sql. Is there any way to set up this cron job like this?

    Thanks. :)
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    16,479
    Likes Received:
    421
    Trophy Points:
    583
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    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