I'm using this string to backup via comand line (SQLCMD) a db on sql.
BACKUP DATABASE [NameDB] TO DISK = N'c:\SqlDB\NameDB.bak' WITH NOFORMAT, NOINIT, NAME = N'NameDB-Full DB Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
I wish, through windows "Scheduled task", run daily backups.
Obviously the file would be overwritten.
Is it possible to scan the string with a batch file, searching the filename and appending it with a time stamp?
example NameDB.bak becomes NameDBYYYYmmddhhmm.bak (NameDB201103151400.bak )
NibbioTNT
thx
Replacing a string with timestamp
Moderator: DosItHelp
-
- Posts: 79
- Joined: 13 Dec 2010 10:32
Re: Replacing a string with timestamp
Well, in batch this can get you a timestamp. Not sure if this helps:
Code: Select all
echo %date:~-4%%date:~-7,2%%date:~-10,2%%time:~0,2%%time:~3,2%
-
- Posts: 319
- Joined: 12 May 2006 01:13
Re: Replacing a string with timestamp
ChickenSoup wrote:Well, in batch this can get you a timestamp. Not sure if this helps:Code: Select all
echo %date:~-4%%date:~-7,2%%date:~-10,2%%time:~0,2%%time:~3,2%
as usual, the output of this method is dependent on regional settings on the individual computer its run on. You will have to do some tweaks to it, (that's why i say batch s**ks) , or use vbscript (powershell)
Re: Replacing a string with timestamp
thx, i'll try it
Re: Replacing a string with timestamp
Code: Select all
for /f "skip=1 delims=." %%d in ('WMIC OS Get LocalDateTime') do echo %%d
Re: Replacing a string with timestamp
Good idea, !k. I had some problems to save the value in a variable. I guess it has to do with the fact that the output is encoded in unicode little endian. For some reason when I tried...
... I found only a CR character in %timestamp%.
This worked:
Regards
aGerman
Code: Select all
for /f "skip=1 delims=." %%d in ('WMIC OS Get LocalDateTime') do set "timestamp=%%d"
... I found only a CR character in %timestamp%.
This worked:
Code: Select all
for /f "skip=1 delims=." %%d in ('WMIC OS Get LocalDateTime^|findstr .') do set "timestamp=%%d"
Regards
aGerman