Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Administration - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 6525

Backup and Restore Plan

$
0
0
I need to backup and restore 10 databases from a MSSQL 2008 server to an MSSQL 2014 server.Below is my plan of execution. I was hoping I could get some input on whether this is a good plan or not or maybe missing something. I tried it on a test database and it seemed to run smoothly.Thanks!Here is the plan:--1) ENABLE disk access[code="sql"] EXEC sp_configure 'show advanced options', 1 RECONFIGURE EXEC sp_configure 'xp_cmdshell', 1 RECONFIGURE [/code]--2) VERIFY[code="sql"] RESTORE VERIFYONLY FROM DISK = N'C:\Backups\Test_Staging_20151216_102557.BAK' WITH CHECKSUM, --RENAME FILES HERE IF NEEDED/PATH TO NEW LOCATION MOVE N'myDB002_dat' TO N'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQL14\MSSQL\DATA\Test_Staging.mdf', MOVE N'myDB002_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQL14\MSSQL\DATA\Test_Staging_log.ldf'[/code]--3) RESTORE DB WITH MOVE(move files to new locations):[code="sql"] USE [master] RESTORE DATABASE [Test_Staging] FROM DISK = N'C:\Backups\Test_Staging_20151216_102557.BAK' WITH FILE = 1, --RENAME FILES HERE IF NEEDED/PATH TO NEW LOCATION MOVE N'myDB002_dat' TO N'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQL14\MSSQL\DATA\Test_Staging.mdf', MOVE N'myDB002_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQL14\MSSQL\DATA\Test_Staging_log.ldf', CHECKSUM, REPLACE, STATS = 10[/code]--4) generates sql command to find orphaned users in each user database[code="sql"] USE master SELECT 'USE '+ name+ ' EXEC sp_change_users_login ''Report'' ' FROM sys.databases WHERE name not in ('master','msdb','model','distribution','tempdb') ORDER BY name[/code]--5) execute script on specified database [code="sql"]USE Test_Staging EXEC sp_change_users_login 'Report' [/code]--6) Try autofix on orphaned user [code="sql"]EXEC sp_change_users_login 'Auto_Fix' , 'testUser';[/code]--7) Specify password if needed [code="sql"]USE [Test_Staging] EXEC sp_change_users_login 'Auto_Fix','testUser',NULL ,'testUser12345'[/code]--8) Verify that user is no longer orphaned [code="sql"]USE Test_Staging EXEC sp_change_users_login 'Report' [/code]--10) Check Database Integrity [code="sql"]DBCC CHECKDB (Test_Staging) WITH NO_INFOMSGS;[/code]--11) Turn off disk access[code="sql"] EXEC sp_configure 'show advanced options', 1 RECONFIGURE EXEC sp_configure 'xp_cmdshell', 0 RECONFIGURE[/code]

Viewing all articles
Browse latest Browse all 6525

Trending Articles