@echo off
::log
IF NOT EXIST .\logs mkdir logs

SET ServerIP=%1
SET ServerPort=%2
SET UserID=%3
SET Passwd=%4
SET RestoreDBName=%5
SET RestoreDBPath=%6

::SET ServerIP=127.0.0.1
::SET ServerPort=1433
::SET UserID=Alis
::SET Passwd=Kefico!@34
::SET RestoreDBName=TestDB
::SET RestoreDBPath=D:\MSSQL\Backup\TestDB.bak

SET SqlCmdOption=-C -U %UserID% -P %Passwd% -S %ServerIP%,%ServerPort% -f 65001 -o .\logs\%RestoreDBName%_Restore.log

sqlcmd %SqlCmdOption% -Q "RESTORE DATABASE [%RestoreDBName%_Restore] FROM DISK='%RestoreDBPath%' WITH REPLACE, MOVE '%RestoreDBName%' TO 'D:\MSSQL\DATA\%RestoreDBName%_Restore.mdf', MOVE '%RestoreDBName%_log' TO 'D:\MSSQL\DATA\%RestoreDBName%_Restore_log.mdf'"

if errorlevel 1 goto errexit
goto end
:errexit
echo DB Restore Fail
goto end
:end
@echo on