RestoreAndUpgrade - termsdev.gratte.com.bat:
@Echo off
set server=46.32.226.206
set database=WASPPSDEV
set user=
set password=
set backupfilepath=C:\FtpRoot\TERMS\Backup\UatServer\Databases\waspps\WASPPSv53.bak
Echo Are you sure you want to overwrite the database %database% on server %server%?
Pause
REM Disconnect All Users
Echo Switching %database% to single user mode to disconnect all other users
sqlcmd /U%user% /P%password% /S%server% /Q "ALTER DATABASE %database% SET SINGLE_USER WITH ROLLBACK IMMEDIATE"
REM Restore the backup
Echo Restoring backup from %backupfilepath%
sqlcmd /U%user% /P%password% /S%server% /Q "RESTORE DATABASE %database% FROM DISK = N'%backupfilepath%' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10"
REM Allow all users back in
Echo Switching %database% to multi user mode to allow user to connect
sqlcmd /U%user% /P%password% /S%server% /Q "ALTER DATABASE %database% SET MULTI_USER WITH ROLLBACK IMMEDIATE"
@Echo Run All Scripts Now?
pause
REM Run All Scripts
for %%f in (*.sql) do sqlcmd /U%user% /P%password% /S%server% /d%database% /i "%%f"
cd..
cd Final_Static_Data
for %%f in (*.sql) do sqlcmd /U%user% /P%password% /S%server% /d%database% /i "%%f"
@Echo All Done
pause
RestoreAndUpgradeLocalServer-Waspps.bat:
@Echo off
set server=.
set database=WASPPS
set user=
set password=
set backupfilepath=%~dp0WASPPSv53.bak
Echo Are you sure you want to overwrite the database %database% on server %server%?
Pause
REM Disconnect All Users
Echo Switching %database% to single user mode to disconnect all other users
sqlcmd /S%server% /Q "ALTER DATABASE %database% SET SINGLE_USER WITH ROLLBACK IMMEDIATE"
REM Restore the backup
Echo Restoring backup from %backupfilepath%
sqlcmd /S%server% /Q "RESTORE DATABASE %database% FROM DISK = N'%backupfilepath%' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10"
REM Allow all users back in
Echo Switching %database% to multi user mode to allow user to connect
sqlcmd /S%server% /Q "ALTER DATABASE %database% SET MULTI_USER WITH ROLLBACK IMMEDIATE"
@Echo Run All Scripts Now?
pause
REM Run All Scripts
@Echo On
for %%f in (*.sql) do sqlcmd /S%server% /d%database% /i "%%f"
cd..
cd Final_Static_Data
for %%f in (*.sql) do sqlcmd /S%server% /d%database% /i "%%f"
@Echo Off
@Echo All Done
pause