I'm writing a bash shell script to backup several mysql databases. This script will run on a daily basis and send a copy to a remote FTP repository. The filenames are in the format DATE.backup.sql. How do I store the DATE variable so I can delete/move/etc the file on the FTP server the next time the script runs?
Code:
#!/bin/bash
DATE=$(date +%d%b%y_%k.%M.%S)
cd /web/.hhome/mysql.backup/data
mysqldump -ubackup -ppassword --databases db1 db3 > $DATE.backup.sql
gzip -9 $DATE.backup.sql
crypt key < $DATE.backup.sql.gz > $DATE.backup.sql.enc.gz
rm -rf $DATE.backup.sql.gz
ftp -inv ftp.somehost.com<<ENDFTP
user hoover90 password
put $DATE.backup.sql.enc.gz
bye
ENDFTP
I can use pretty much any method, but it has to be done within this bash script.
Thanks!