Preface
Database backup is one of the most important tasks of production environment DB server, and regular automatic backup helps us to quickly locate and restore abnormal or problem data, and this blog will simply record how to automate daily backup of data in Windows Server 2008 through scripts and Task Scheduler. Creating Scripts
First create a Windows batch script, which is named Xnzzdb.bat:
@echo off
set adir=%date:~,4%%date:~5,2%%date:~8,2%
exp xnzz/xnzz@xnzzdb file=e:\db_backup\xnzzdb_%adir%. Dmp
You can see the first Adir variable assignment, in fact, this expression is to intercept and splice the specified format date, Adir variable format is actually YYYYMMDD format date.
Second, we are familiar with the exp command, the export must still be through the exp command to achieve, we exported the file path is e disk under the Db_backup directory, and file life is xnzzdb _ threaded the current date (YYYYMMDD format), To verify that it's best to run with the highest privileges to see if you can successfully back up and export files to a specified directory, you can see that I can successfully export this:
And then there's the question of how to execute the script file on a daily basis, which can be implemented through a Task Scheduler in Windows. Create a task
The first is to create a task that you can see in the Attachment –> System tool:
Click Open to see the main screen:
Click on the right side to create a basic task, just enter a name and then click "Next":
Then I choose the frequency of execution, I choose every day here, and then click "Next":
Then set the start time and specific implementation, I choose to do 18 points every day, starting today, and then click Next:
Since we are executing a batch script, simply select "Start Program" and click "Next":
Next is to select the location of our script, if there are parameters, fill in the parameters, click "Next":
Finally confirm that the configuration is correct and click "Finish":
Since we checked the Task Properties dialog box when we clicked "Finish," the next thing we see is the Task Properties dialog box, where we're going to make some more settings:
As shown in the figure above, it is important to check that this is especially important if you want to select "Run with highest privileges, regardless of whether the user is logged on" or not, and the batch script cannot be automatically completed if you do not select both. Finally click "OK" and enter the password:
Finally on the home page you can see just added the task:
Double-click the task to go to the Task Details page and see the last and next execution times and last execution results:
The automatic backup configuration for Oracle 10g on Windows Server is now complete, and the backup script is automatically executed every 18:00 of the day, and the DMP file for the day is generated in the directory we specify. Summary
Simply record the problem and hope to help students with the same problem, the end.