You will need to create your own script, as you really want to do more than backup and restore. Other things you could do is run DBCC UpdateUsage, set the compatibility level, update statistics, run DBCC CheckDB using Data_Purity, change the page check parameter to a checksum. You may also have replications and full-text directories. All of these things would probably have to go into your script.
You will need to set up a script that does all / some / more of the things mentioned earlier in the database and then extends your script to iterate over all your databases. This can be done using a combination of batch files or powershell files and using sqlcmd.
For example, this is one script that I run after restoring the backups to a new server. This is called from the windows batch file via sqlcmd.
USE [master]
GO
ALTER DATABASE [$ (DATABASENAME)] SET COMPATIBILITY_LEVEL = 100
ALTER DATABASE [$ (DATABASENAME)] SET PAGE_VERIFY CHECKSUM WITH NO_WAIT GO
Use [$ (DATABASENAME)]
Go Announcement @DBO sysname
- who is user sa
Select @DBO = name from sys.server_principals Where main_id = 1
- assign sa to database owner
exec ('sp_changedbowner' '' + @DBO + '' '') go
- fix calculations
dbcc updateusage (0) go -check the db enable column value integrity
dbcc checkdb (0) With Data_Purity, ALL_ERRORMSGS, NO_INFOMSGS go
- make sure the statistics are updated
exec sp_updatestats
Go
source share