[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-users] RaQ4 - datestamp filenames in script



Hi folks

I've got a small script running via cron to backup my MySQL databases, it
works but I'd like to amend this to create a new backup file each day with
the date in the filename.  Here's the script as it stands:

----------

#!/bin/sh

# This script lives in /usr/local/bin

DESTINATION_DIR="/home/working/mysql/backups"

mysql -uXXXX -pXXXX < $DESTINATION_DIR/prebackup
mysqldump --opt --all-databases -uXXXX -pXXXX > $DESTINATION_DIR/mysqldump
mysql -uXXXX -pXXXX < $DESTINATION_DIR/postbackup

# Tar and gZip the logs
rm $DESTINATION_DIR/mysqldump.tar.gz
tar cvfz $DESTINATION_DIR/mysqldump.tar.gz $DESTINATION_DIR/mysqldump

chown -R admin:admin $DESTINATION_DIR

----------

What I'd like to see is the date appended to the filename, i.e.
mysqldump30012003.tar.gz - the format of the date is not important to me so
long as it's recognisable.

Can anyone assist?

Many thanks,
Tim Skipper