I run the following script:
#!/bin/bash
{
date=$( date '+%Y-%m-%d_%H-%M-%S' )
file="mysql_dump_$date"
echo '###Start DB Backup '$date'###'
mysqldump -h localhost -u 'USERNAME' -pPASSWD 'DBNAME' > /backup/$file
echo '###DB Backuo Finished '$date'###'
} >> /backup/backup.log
As you can see in the mysqldump line, $file will be named mysql_dump_date
I would like to cp the file somewhere else but don't know how I can specify to use the $file which is used in the mysqldump line. Obviously, I could just used $file but if the DB backup starts at 10:49:59 and the cp will start at 10:50:00, it won't have the same timestamp and wouldn't be able to find the file and the copy would fail.
Any ideas?