Backup | timing | data | database
About database automatic scheduled backups, but each backup with a different name
This method may be realized a long time ago, I hope which masters do not mind, =:)
Again, the database is scheduled to be backed up automatically, but each backup is implemented with a different name as follows:
1: Create a job on SQL Server that will allow it to run automatically and regularly;
2: Create a step with the following code:
declare @path nvarchar (100)
declare @name nvarchar (100)
declare @devicename nvarchar (50)
--' F:\backup\DBback ', this is free to replace, the backup name with date as a different name
Set @path = ' F:\backup\DBback ' + convert (nvarchar), GETDATE (), 112) + '. Dat '
--25,28 A number like this, changes with the previous path
Select @name = substring (@path, 25,len (@path)-28)
Select @devicename = @name
EXEC sp_addumpdevice ' disk ', @devicename, @path
--dbname is the database you want to back up.
BACKUP DATABASE dbname to @devicename
Go
3: Then establish a schedule, so that it can be a certain amount of time to back up the different names of the database, and later recovery is also very convenient, want to restore which to restore which. =:)