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.

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

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

  1. nic_net

    nic_net Registered

    Joined:
    Nov 29, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    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:
    451
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Vancouver, Canada
  3. nic_net

    nic_net Registered

    Joined:
    Nov 29, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    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