我正在从 1 个 Server 2012 盒子移动到另一个 Server 2012 盒子。我正在尝试将我的 SQL Server 2012 Express 实例(数据库、登录名等)完全从一台服务器移动到另一台服务器。
最简单的方法是什么?我刚刚意识到我的.bak
备份并没有像我想象的那样恢复。
这是我备份数据库的代码。
REM @ECHO OFF
SETLOCAL
REM Get date in format YYYY-MM-DD (assumes the locale is the United States)
FOR /F "tokens=1,2,3,4 delims=/ " %%A IN ('Date /T') DO SET NowDate=%%D-%%B-%%C
REM Build a list of databases to backup
SET DBList=%SystemDrive%SQLDBList.txt
SqlCmd -E -S LOCALHOST\SQLEXPRESS -h-1 -W -Q "SET NoCount ON; SELECT Name FROM master.dbo.sysDatabases WHERE [Name] NOT IN ('tempdb')" > "%DBList%"
REM Backup each database, prepending the date to the filename
FOR /F "tokens=*" %%I IN (%DBList%) DO (
ECHO Backing up database: %%I
SqlCmd -E -S LOCALHOST\SQLEXPRESS -Q "BACKUP DATABASE [%%I] TO Disk='C:\SQLBackup\Database\MSSQL\%NowDate%_%%I.bak'"
ECHO.
)
REM Clean up the temp file
IF EXIST "%DBList%" DEL /F /Q "%DBList%"
ENDLOCAL
如何用这个恢复数据?