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!

How do I backup a database using a cron job and send it by mail?

Discussion in 'E-mail Discussion' started by nic_net, Nov 29, 2006.

  1. nic_net

    nic_net Registered

    Joined:
    Nov 29, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    151
    How can i do a database backup using a cron job and send it by mail?

    Hello,

    I would like to backup only a database (forum.gz) using a cron job and them send the file by mail to a gmail account.

    What should I type in the command line ?? Please help me!

    I really appreciate it if someone replied .

    Thanks :eek:
     
    #1 nic_net, Nov 29, 2006
    Last edited: Nov 29, 2006
  2. Stefaans

    Stefaans Well-Known Member

    Joined:
    Mar 5, 2002
    Messages:
    456
    Likes Received:
    3
    Trophy Points:
    318
    Location:
    Vancouver, Canada
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. nic_net

    nic_net Registered

    Joined:
    Nov 29, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    151
    I do it:

    Code:
    # Nico backup 1.0
    # 29-11-06
    
    # Email donde se enviara
    EMAIL="usermail@domain.com"
    
    # Orden de crear el backup
    mysqldump --opt -u USERNAME -pPASSWORD DBNAME >>  /home/backups/file1.sql
    
    # Variable fecha
    DATE=`date +%Y%m%d`
    
    # De .sql a .gz
    gzip file1.sql
    
    # Renombro con la fecha el .gz
    mv file1.sql.gz backup-$DATE.sql.gz
    
    # Envio por e-mail
    echo 'Aqui tienes el backup de hoy.' | mutt -a backup-$DATE.sql.gz $EMAIL -s "MySQL Backup"
    
     
    #3 nic_net, Nov 29, 2006
    Last edited: Nov 29, 2006
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