LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   some script-question (https://www.linuxquestions.org/questions/linux-newbie-8/some-script-question-41129/)

G.P.P. 01-11-2003 05:06 PM

some script-question: date as filename
 
i would like to have a script for making a backup of my data on a webserver...
i thought of first savin the database to some *sql
and then zipping all files...
...this is no problem, but it would be usefull, if i could rename the files in the way that the date is patr of filename... but how to involve the date into filename?!

the so-far-script:
Code:

mysqldump -uusername -p database > ~/www/db.sql
zip -R -9 -o ~/bak/latestbak ~/www/*


acid_kewpie 01-11-2003 05:29 PM

you'd use backticks in the zip command

zip -R -9 -o ~/bak/backup-`date +%m-%d-%Y` ~/www/*

seems to make sense. you would have been able to jsut say date +%D but the standard date output contains /'s which is no use in a filename now is it? good golly no.

J_Szucs 01-11-2003 05:30 PM

DATESTRING=`date +"%Y%m%d"`

One must be very quick here.
Acid_kewpie posted a complete answer while I was pulling together some information to post my short one.

But I have a question: does zip store permissions in the archive? Not so long ago I throwed away zip and rather used tar + gzip for this purpose because zip did not seem to store the permission information with the archived files.

G.P.P. 01-11-2003 05:41 PM

Thank you guys, also for your swiftness... This'll help me!


All times are GMT -5. The time now is 12:32 PM.