I'd like to run a simple tar command to backup my website directory. It will run through cron, but I want to be able to put the time at which the backup was made as the filename. I don't really mind what format it's in, but something vaguely readable would be good. I'm just looking for a generic command; a way of putting the date in the filename - I can do the rest of the tar stuff.

Thanks,

James

link|improve this question

feedback

1 Answer

up vote 5 down vote accepted
tar cfz backup-$(date +%Y-%m-%d).tar.gz ...

man strftime or man date to see what %-escapes can be used with date.

link|improve this answer
Thank you :-) I found the date thingy before, but couldn't get it to work for some reason. Geekosaur saves the day! – JamWaffles Mar 11 '11 at 19:11
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.