I have scheduled backup script that makes the database dump. How can I add the date timestamp to the file name?
I am talking about Windows and CMD.
|
|
|
In the command prompt and batch files, you can use Use something like:
This will produce a filename such as |
|||||||||||||||||||
|
|
Use the theory » echo %date% 2009-06-01 theory » echo %time% 16:30:41,46 theory » echo %time::=% 163052,17 theory » echo %time::=,% 16,30,58,68 theory » echo backup-%date%-%time::=-%.zip backup-2009-06-01-16-31-18,82.zip |
|||
|
|
|
Use %DATE% variable in the filename. There is a %TIME% variable as well, but it contains characters not allowed in a file name. Here is an example of writing a line of text into a new file, where the file created has a date and time in its name.
|
|||
|
|
|
I know the question wasn't about Unix, but for completeness, here's how to do it in bash:
|
|||
|
|