Results 1 to 7 of 7

Thread: MySQL Cron job

  1. #1
    Join Date
    Jan 2003
    Location
    London
    Posts
    144

    MySQL Cron job

    I have a DL360G4 with RHES Linux 4 and Apache 2.0.x. I have set up a cron job to dump a mysql database to an sql file daily.

    /usr/bin/mysqldump -uxxxx -pxxxx database > /path/to/file.sql

    I also want to tarball it. Would I have to set up another cron job say a minute later to do that or is there a better way.

    Bob

  2. #2
    Join Date
    May 2002
    Location
    Moscow
    Posts
    1,490
    you may code simplebash scrpits for this:

    #!/bin/bash
    /usr/bin/mysqldump -uxxxx -pxxxx database > /path/to/file.sql
    sleep 5
    /path/tar -czxf file.sql.tgz /path/to/file.sql

    and run it by cron
    Rustelekom LLC Dedicated server since 2002, RIPE NCC member, LIR, AS51168

  3. #3
    You need not tar it because you have only one file
    it is enough to gzip only

    /usr/bin/mysqldump -uxxx -pxxx database | gzip >/path/database.sql.gz

    or bzip2 for better compression

    /usr/bin/mysqldump -uxxx -pxxx database | bzip2 >/path/database.sql.bz2

    if you wish I can help you write script to make backup to remote server
    Last edited by grubber; 08-05-2005 at 03:03 AM.

  4. #4
    I recommend you this script which names "automysqlbackup".

    Look it at Google with two words: "automysqlbackup" and "sourceforge"
    Since I have not posted on this forum, by now, more that 5 times, the forum program does let me publish full URL here :-(


    A script to take daily, weekly and monthly backups of your MySQL databases using mysqldump. Features - Backup mutiple databases - Single backup file or to a seperate file for each DB - Compress backup files - Backup remote servers - E-mail logs - More..

    I use for two years and had never probelm and what is good that you get mail reports and saves daily/weekly/monthly backups. It happened once when one table was corrupted and MySQL could not perform backup, instead of 50 Mb file it was only ~15Kb. I saw it immediatelly and fixed the same day!
    It was good because just few weeks later I was hacked and could restore to most latest condition just in minutes.

    Otherwise I could not have any backup at all!!!

  5. #5

  6. #6
    Join Date
    Jan 2003
    Location
    London
    Posts
    144
    Excellent, many thanks.

    Bob

  7. #7
    Thats a nice looking script, Well commented and easy to follow. Might have to give it a try.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •