对某服务器上的多个用户备份,自动删除N月前的备份数据
参数配置(需要管理员初始化)
DelFileByDay 删除N天前的备份文件
OracleSID @这个后面应该跟的是a中的名称,而不是数据的sid。
Home_BackupTarget 备份文件的远程存放位置
set Home_Winrar=CProgram FilesWinRAR
set Home_BackupTarget=GEPM
set DelFileByDay=7
set OracleServerName=
set OracleSID=ORCL_127.0.0.1
set User01=
set User02=
set User03=
set User04=
set User05=
set User06=
set User07=
set User08=
set User09=
set User10=
set User11=
set User12=
set User13=
set User14=
set User15=
set Pass01=
set Pass02=
set Pass03=
set Pass04=
set Pass05=
set Pass06=
set Pass07=
set Pass08=
set Pass09=
set Pass10=
set Pass11=
set Pass12=
set Pass13=
set Pass14=
set Pass15=
生成日期
---------------------- 用于备份
set CurrentDateTime=%date~0,10%#%time~0,6%
set CurrentDateTime=%CurrentDateTime=%
set CurrentDateTime=%CurrentDateTime-=%
set CurrentDateTime=%CurrentDateTime =%
set CurrentDateTime=%CurrentDateTime=%
重新设置变量
set Home_Backup=%~dp0
set Home_Backup_Oracle=%Home_Backup%Oracle
set Home_backup_Oracle_TO=%Home_BackupTarget%Oracle
set Home_Winrar_EXE=%Home_
创建新的文件
set FileName_01=%Home_Backup_Oracle%%CurrentDateTime%_%User01%
set FileName_02=%Home_Backup_Oracle%%CurrentDateTime%_%User02%
set FileName_03=%Home_Backup_Oracle%%CurrentDateTime%_%User03%
set FileName_04=%Home_Backup_Oracle%%CurrentDateTime%_%User04%
set FileName_05=%Home_Backup_Oracle%%CurrentDateTime%_%User05%
set FileName_06=%Home_Backup_Oracle%%CurrentDateTime%_%User06%
set FileName_07=%Home_Backup_Oracle%%CurrentDateTime%_%User07%
set FileName_08=%Home_Backup_Oracle%%CurrentDateTime%_%User08%
set FileName_09=%Home_Backup_Oracle%%CurrentDateTime%_%User09%
set FileName_10=%Home_Backup_Oracle%%CurrentDateTime%_%User10%
set FileName_11=%Home_Backup_Oracle%%CurrentDateTime%_%User11%
set FileName_12=%Home_Backup_Oracle%%CurrentDateTime%_%User12%
set FileName_13=%Home_Backup_Oracle%%CurrentDateTime%_%User13%
set FileName_14=%Home_Backup_Oracle%%CurrentDateTime%_%User14%
set FileName_15=%Home_Backup_Oracle%%CurrentDateTime%_%User15%
set FileNameNew_OracleData=%CurrentDateTime%_ORACLE.rar
创建文件夹
CALL MD %Home_Backup_Oracle%
CALL MD %Home_backup_Oracle_TO%
删除备份文件
---- 删除N天前的备份数据(本地)
call forfiles P %Home_Backup_Oracle% D -%DelFileByDay% C CMD C DEL @FILE
---- 删除N天前的备份数据(远程)
call forfiles P %Home_backup_Oracle_TO% D -%DelFileByDay% C CMD C DEL @FILE
---- 删除文件名相同的备份文件,之后重新备份
del %FileName_01%.dmp %FileName_01%.log
del %FileName_02%.dmp %FileName_02%.log
del %FileName_03%.dmp %FileName_03%.log
del %FileName_04%.dmp %FileName_04%.log
del %FileName_05%.dmp %FileName_05%.log
del %FileName_06%.dmp %FileName_06%.log
del %FileName_07%.dmp %FileName_07%.log
del %FileName_08%.dmp %FileName_08%.log
oracle数据库自动备份方法del %FileName_09%.dmp %FileName_09%.log
del %FileName_10%.dmp %FileName_10%.log
del %FileName_11%.dmp %FileName_11%.log
del %FileName_12%.dmp %FileName_12%.log
del %FileName_13%.dmp %FileName_13%.log
del %FileName_14%.dmp %FileName_14%.log
del %FileName_15%.dmp %FileName_15%.log
备份Oracle
if defined OracleServerName (set OracleSID=%OracleServerName%%OracleSID%)
if defined User01 (if defined Pass01 (call exp %User01%%Pass01%@%OracleSID% owner=%User01% file=%FileName_01%.dmp log=%FileName_01%.log))
if defined User02 (if defined Pass02 (call exp %User02%%Pass02%@%OracleSID% owner=%User02% file=%FileName_02%.dmp log=%FileName_02%.log))
if defined User03 (if defined Pass03 (call exp %User03%%Pass03%@%OracleSID% owner=%User03% file=%FileName_03%.dmp log=%FileName_03%.log))
if defined User04 (if defined Pass04 (call exp %User04%%Pass04%@%OracleSID% owner=%User04% file=%FileName_04%.dmp log=%FileName_04%.log))
if defined User05 (if defined Pass05 (call exp %User05%%Pass05%@%OracleSID% owner=%User05% file=%FileName_05%.dmp log=%FileName_05%.log))
if defined User06 (if defined Pass06 (call exp %User06%%Pass06%@%OracleSID% owner=%User06% file=%FileName_06%.dmp log=%FileName_06%.log))
if defined User07 (if defined Pass07 (call exp %User07%%Pass07%@%OracleSID% owner=%User07% file=%FileName_07%.dmp log=%FileName_07%.log))
if defined User08 (if defined Pass08 (call exp %User08%%Pass08%@%OracleSID% owner=%User08% file=%FileName_08%.dmp log=%FileName_08%.log))
if defined User09 (if defined Pass09 (call exp %User09%%Pass09%@%OracleSID% owner=%User09% file=%FileName_09%.dmp log=%FileName_09%.log))
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论