mysqldump/cron job help

Hi all,

Im trying to rename my backup file to backup-“the-time-here”.sql using mysqldump via cron jobs.

I have the cron job backing up the file at the correct times but when im trying to put in the time its giving me a file like this.

( i cant find any examples of just the time so i know that the code below includes the date)

backup-Monday 13-10-2012 13:01:02.sql < - this is giving me an invalid file?

any help would be great.

my cron job code

          • mysqldump --username=USERNAME --password=Password DATABASENAME > /pathtobackuplocation/backup-date +%y%m%d.sql

Thanks Ian

This is funny I was just about to write a post about this. You have the right idea just not the correct implication.

Here is my implementation

Cron job (crontab -e)

@hourly LOCATION_OF_YOUR_SCRIPT/backup.sh or* */1 * * * LOCATION_OF_YOUR_SCRIPT/backup.sh

Then you need a shell script mine looks like this

#!/bin/sh DATE=$(date +%m-%d-%Y_%H:%M:%S) mysqldump -u USERNAME -p'YOURPASSWORD' --all-databases > /services/web/database_backups/$DATE.sql gzip -f /services/web/database_backups/$DATE.sql

this runs Hourly but a simple search on cron scheduling and you can run it when ever you like.

Hi Andrew,

Thanks a lot for getting back to me. In the end i just set up two cron jobs for the needed times and named them differently, i will read up more about shell scripts and try and get my head around it.

Thanks

Ian

Sponsor our Newsletter | Privacy Policy | Terms of Service