Learn to build secure applications from the mindset of the hacker and avoid being exploited.
:: Get FTP files
ECHO OFF
CLS
rem ECHO Getting FTP files...
rem "C:\Program Files (x86)\coreftp\coreftp.exe" -s -O -site ISI -d /*.zip -p "F:\TeamDB\New backups"
ECHO Extracting zips...
fastzip -x -overwrite=always "F:\TeamDB\New backups\db.zip" .
fastzip -x -overwrite=always "F:\TeamDB\New backups\files.zip" "F:\TeamDB\New backups\ISIFiles"
::SET VARIABLES
set DBNAME=ISP-MIS
set DBDIRECTORY=F:\ISI Databases
::rem set DBDIRECTORY=D:\Databases
ECHO Restoring %DBNAME% Database
ECHO PUT DATABASE IN SINGLE USER MODE TO ALLOW RESTORE
osql -S ISI-SQL\ISIDB -E -d master -Q "alter database [%DBNAME%] set single_user with rollback immediate"
ECHO RESTORE DATABASE
:: rem osql -S ISI-SQL\ISIDB -E -d master -Q "restore FILELISTONLY from disk='%~dp0\%DBNAME%.bak' "
sqlcmd -S ISI-SQL\ISIDB -E -d master -Q "restore database [ISP-MIS] from disk='%~dp0\ISP-MIS.bak' WITH MOVE 'R%DBNAME%_Data' TO '%DBDIRECTORY%\%DBNAME%.MDF', MOVE 'R%DBNAME%_Log' TO '%DBDIRECTORY%\%DBNAME%_Log.LDF', REPLACE "
::GRANT PERMISSION TO ASPNET USER
::rem osql -S ISI-SQL\ISIDB -E -d %DBNAME% -Q "sp_grantdbaccess '%COMPUTERNAME%\ASPNET'"
::rem osql -S ISI-SQL\ISIDB -E -d %DBNAME% -Q "sp_addrolemember 'db_owner', '%COMPUTERNAME%\ASPNET'"
ECHO RESTORE TO MULTI USER
osql -S ISI-SQL\ISIDB -E -d master -Q "alter database [%DBNAME%] set multi_user"
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
task.bat >> %USERPROFILE%\documents\task.log 2>&1
task.bat >> %USERPROFILE%\documents\task.log 2>&1
Experts Exchange Solution brought to you by
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
Start your 7-day free trialFrom novice to tech pro — start learning today.
Experts Exchange Solution brought to you by
The user that you specify is the user that will run the script so must have the correct rigths