Windows下Oracle自动备份
1 @echo off
2
3 set t_date=%date%
4 set t_time=%time%
5
6 set t_n=%t_date:~0,4%
7 set t_y=%t_date:~5,2%
8 set t_r=%t_date:~8,2%
9 set t_h=%t_time:~0,2%
10 set t_m=%t_time:~3,2%
11
12 set full_name=CTEurope%t_y%%t_r%%t_h%%t_m%
13
14 exp eutest/1@gentle file=%full_name%.dmp
15
16 "C:\Program Files\WinRAR\Rar.exe" a -k -r -s -m1 %full_name%.rar %full_name%.dmp
17
18 del %full_name%.dmp
2
3 set t_date=%date%
4 set t_time=%time%
5
6 set t_n=%t_date:~0,4%
7 set t_y=%t_date:~5,2%
8 set t_r=%t_date:~8,2%
9 set t_h=%t_time:~0,2%
10 set t_m=%t_time:~3,2%
11
12 set full_name=CTEurope%t_y%%t_r%%t_h%%t_m%
13
14 exp eutest/1@gentle file=%full_name%.dmp
15
16 "C:\Program Files\WinRAR\Rar.exe" a -k -r -s -m1 %full_name%.rar %full_name%.dmp
17
18 del %full_name%.dmp
然后将这个bat文件添加到windows的任务计划中,设置每隔多少时间运行一次,备份文件会自动以当前时间来保存并压缩。
注意:当用户名或者密码中,含有特殊字符时,需要用"""将其包含进来,这样才可以导出,例如:
用户名:zhangxd
SID:mydb
则导出命令应该是:exp zhangxd/"""密码"""@mydb log=log.txt