Part of a batch file I'm creating is refreshing a sql database from a script being called on a different server. I'd like to be able to check if the remote sql backup file is of the current date and not earlier. This will insure I'm restoring the most current backup.
Can anyone advise a method to check this in the batch file? I'd like to have a line where it checks this and if the date of the backfile (fscm_fullback.bk) is current to continue running the balance of the script, and if not abort script.
Appreciate insight/ideas.
Determine remote file -date stamp
Moderator: DosItHelp
Re: Determine remote file -date stamp
Code: Select all
set "backup=fscm_fullback.bk"
for /f "tokens=1,2" %%a in ('dir "%backup%" ^|findstr /lic:"%backup%"') do (
set "backupdate=%%a"
set "backuptime=%%b"
)
if not "%backupdate%"=="%date%" exit /b 1
-
- Posts: 7
- Joined: 21 Apr 2010 12:03
Re: Determine remote file -date stamp
Thanks for the reply. I would want to check for the existence of the file against a remote server that it sits on. The script you wrote looks like it would check the local server that the script is running on?
Would WMIC work for remote file check, any ideas?
Would WMIC work for remote file check, any ideas?
Re: Determine remote file -date stamp
PSexec from PStools can run scripts on a remote server.
On the other hand if you are using FTP to gather the files then you can check the datestamp on the FTP server.
On the other hand if you are using FTP to gather the files then you can check the datestamp on the FTP server.