troff
09-13-2004, 11:45 PM
I just spent 4 days trying to find out in console how to output a time formatted file, just thought I'd share it with you all.
You can use the following with mysqldump in order to back up your mysql database. I use this in conjunction with an automated ftp at another location (e.g. Meteor FTP) that downloads it at 2am every day.
For now here is the script that allows you to assign a time-based filename:
---------------
#!/bin/bash
prefix=mysql-dbname-
suffix=`eval date +%Y-%m-%d`
extenx=.sql
filename=$prefix.$suffix.$extenx
echo $filename
# It's great for creating "unique" temp filenames,
#+ even better than using $$.
# Read the 'date' man page for more formatting options.
-----------------
This will give you a filename of mysql-dname-2004-09-14.sql for example.
If you place this in cron.daily or crontab at 2am it can back up your sql dumps (make sure it is with structure and complete inserts I think).
You can use the following with mysqldump in order to back up your mysql database. I use this in conjunction with an automated ftp at another location (e.g. Meteor FTP) that downloads it at 2am every day.
For now here is the script that allows you to assign a time-based filename:
---------------
#!/bin/bash
prefix=mysql-dbname-
suffix=`eval date +%Y-%m-%d`
extenx=.sql
filename=$prefix.$suffix.$extenx
echo $filename
# It's great for creating "unique" temp filenames,
#+ even better than using $$.
# Read the 'date' man page for more formatting options.
-----------------
This will give you a filename of mysql-dname-2004-09-14.sql for example.
If you place this in cron.daily or crontab at 2am it can back up your sql dumps (make sure it is with structure and complete inserts I think).
