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 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:
    1
    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:
    14,453
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
Loading...

Share This Page