Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    4

    Post 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
    Last edited by nic_net; 11-29-2006 at 12:26 PM.

  2. #2
    Member Stefaans's Avatar
    Join Date
    Mar 2002
    Location
    Vancouver, Canada
    Posts
    445

    Default

    This seems like the script what you are looking for: http://members.lycos.co.uk/wipe_out/automysqlbackup/

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    4

    Default

    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"
    Last edited by nic_net; 11-29-2006 at 01:37 PM.

Similar Threads & Tags
Similar threads

  1. Cron Job to back up MySQL database
    By BMR777 in forum New User Questions
    Replies: 1
    Last Post: 01-30-2010, 07:24 PM
  2. Replies: 0
    Last Post: 01-22-2010, 05:53 PM
  3. cron job to backup database and email the attachment
    By gatzke in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 10-11-2009, 11:23 AM
  4. Replies: 2
    Last Post: 12-24-2006, 10:30 PM
  5. cron job - command to backup a database ?
    By king007 in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 08-17-2006, 06:11 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube