Running cron to restore SQL backup

Discussion in 'Site & Server Administration' started by bigpapa, Nov 9, 2008.

  1. #1
    Im setting up a cron job to automatically restore .sql.gz database dump, and it can be done simply like this:

    mysql -uUSERNAME -pPASSWORD database < /home/username/sqlbackups/backup.sql 
    Code (markup):
    The only thing is that each time my database is backed up, it gets assigned a different name, like dbname_38384923_23923.sql.gz and the old one is deleted, so at any time there is only 1 sql dump in my backup directory.


    How can I modify a cron job to just backup ANY existing database that resides in a specified directory?

    Thanks for any help.
     
    bigpapa, Nov 9, 2008 IP