Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron to create new folder

Status
Not open for further replies.

twiSSt

Programmer
Mar 25, 2004
282
US
I have a crontab that backs up my Mysql database, code as follows

mysqldump -u root --all-databases > /Volumes/BackupWeekly/mysql_backup.sql. This is the weekly, and i also have daily.
That is working fine. What i need to do now is have create a new folder each time it executes, because in it's current form it is overwriting the last file.

Twist

===========================================
Everything will be OK in the end.
If it's not OK, then it's not the end
 
What about something like this ?
mysqldump -u root --all-databases > /Volumes/BackupWeekly/mysql_backup`date +%Y%m%d`.sql

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I have tended to use another set of CRONTAB entries to move the previous day reports into one of the underlying Sunday to Saturday directories before running the current backup.
That keeps a minimum 6 day set available.

Ed Fair
Give the wrong symptoms, get the wrong solutions.
 
Thanks you both for your quick response. Cron is a new concept to me, as most of my experience is with windoz administration, but we are also using a Mac X-Serve and the guy who handled admin on it has left the company and it's now my baby. While checking the backups (daily and weekly) I found that it was overwriting and some historical data was lost.

Twist

===========================================
Everything will be OK in the end.
If it's not OK, then it's not the end
 
I'd go with PHV's suggestion, but if you're intending to include the `date +%Y%m%d` in your crontab, remember to escape the % signs like this:

`date +\%Y\%m\%d`

Otherwise cron treats the first % as the end of the command. An interesting feature I picked up here on Tek-Tips the other week. Note also that the ` are backticks (above the tab key on my (UK) keyboard), not regular apostrophes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top