A simple, fully-prepared database script, @path parts need to replace the path
1 DECLARE @name VARCHAR( -)--Database name2 DECLARE @path VARCHAR( the)--path for backup files3 DECLARE @fileName VARCHAR( the)--filename for backup4 DECLARE @fileDate VARCHAR( -)--used for file name5 6 --Specify database backup directory7 SET @path = 'C:\Backup\' 8 9 --Specify filename formatTen SELECT @fileDate = CONVERT(VARCHAR( -),GETDATE(), the) One A DECLAREDb_cursorCURSOR for - SELECTname - frommaster.dbo.sysdatabases the WHEREName not inch('Master','Model','msdb','tempdb')--Exclude These databases - - OPENDb_cursor - FETCH NEXT fromDb_cursor into @name + - while @ @FETCH_STATUS = 0 + BEGIN A SET @fileName = @path + @name + '_' + @fileDate + '. BAK' at BACKUP DATABASE @name to DISK = @fileName - - FETCH NEXT fromDb_cursor into @name - END - - CLOSEDb_cursor in deallocateDb_cursor
Can see does not back up ' master ', ' model ', ' msdb ', ' tempdb ' database
To make it easier to handle orphaned accounts, it is recommended that you back up the master database. Or 2012 of the include database is enabled, but it is also recommended to back up the master database
Although the model database does not have any user data in it, the database in which tempdb needs to be created through the model parameters is also recommended for backup.
MSDB records Some schedule information about the SQL Agent and backup restore information, and it is recommended to back it up, and it is recommended to use the full recovery model in a redundant device.
Tempdb is created when the database starts, so no backup is required.
Reference
http://www.mssqltips.com/sqlservertip/1070/simple-script-to-backup-all-sql-server-databases/
A simple, fully-prepared database script and whether the system database needs to be backed up