Backing up server data is a troublesome thing, and it is naturally very painful if you have to back it up manually every day or often. Here I introduce a method to establish automatic backup through sql server job scheduling:
1. Enter the enterprise manager->Management->sql server agent->Job;
2. Create a new job , choose the name of the job at will, for example: data backup, choose sa as the owner, of course you can also choose other users, provided that the user has the permission to execute the job;
3. Click the step label to enter the step panel. Create a new step. The step name can be filled in casually, such as step 1. The type and database are default and do not need to be modified. Write the following statement in the command:
BACKUP DATABASE [database name] TO DISK = N'F: database backup' WITH NOINIT, NOUNLOAD, NAME = N'database backup', NOSKIP, STATS = 10, NOFORMAT
Note : The place that needs to be modified, the database name, DISK= (you need to fill in the path and the name of your database backup here) and the following Name= can be filled in casually.
4. Click the Scheduling tab, enter the Scheduling panel, create a new schedule, fill in the name as you like, select recurring, and click Change to select any schedule you want to perform the task. Such as every day, every 2 days, every week, every month, etc. Set it according to your needs;
5. After confirmation, don’t forget one thing. Right-click on the job you just created to start the job. If there is no problem with your job, it will prompt that the execution was successful and there will be a corresponding message. The backup file appears on your disk;
6. Another important issue is that your sql server agent server has been started.
If we need to generate a new backup based on the date of each day so that we can distinguish the backup files. At this time, we need to modify the sql statement just now. Reference example:
declare @filename nvarchar(100) set @filename='F: database backup RBdata' convert(char(10),getdate(),112) print @filename BACKUP DATABASE [addin] TO DISK = @filename WITH NOINIT , NOUNLOAD , NAME = N' BACKUP ', NOSKIP , STATS = 10, NOFORMAT