If you are using SQL Express, you
can use the following process to automate the SQLCMD Backup command.
First, you need to create a SQL script using the command you ran from
the command line:
BACKUP DATABASE vCenter TO DISK = N'S:\Backup\vCenter.bak'
The file extension does not matter, but in
this case save the database with a .bak extension so that it is easy to
identify. Now you need to create a scheduled task to initiate the
SQLCMD command and execute the SQL script. You also need to create a
local ID under which the scheduled task can run with suitable
privileges including the logon as batch job privilege.
You can add a policy through the Active Directory (AD) by separating
out your vCenter Server in a separate OU. You should do this through
Active Directory policy, but you can configure this locally by doing
the following:
1. Navigate to Administrative Tools\Local Security Policy.
2. Expand the Security Settings\Local Policies\User Rights Assignment.
3. Add the account that will run the scheduled job to the Logon as Batch Job Properties and click OK.
When you are done, you can open the scheduler to create a basic task.
1. Open the scheduler on the SQL Express Server and create a basic task. Provide a descriptive name such as vCenter Backup job and a description of when the job occurs, as shown in Figure 16. Then click Next.
Figure 16. Create a Task.
2. Configure the trigger; in this case, set up the backup job to be triggered weekly (see Figure 17). Then click Next.
Figure 17. Configure a trigger (weekly).
3. Set the frequency you would like the backup to occur at (see Figure 18) and click Next. If you would like the backup to happen every two weeks, you can adjust the Recur setting from 1 to 2.
Figure 18. Determine the schedule and reoccurrence.
4. Set it to start the SQLCMD command with arguments. To do so, select Start a Program (see Figure 19). Then click Next.
Figure 19. Select Start a Program.
5. Select the SQLCMD program and the argument as –i [Path to your SQL script], as shown in Figure 20.
Figure 20. Select SQLCMD as the program and your script as the arguments.