-
Notifications
You must be signed in to change notification settings - Fork 2
/
DBBackup.xml
174 lines (158 loc) · 9.35 KB
/
DBBackup.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?xml version="1.0" encoding="UTF-8"?>
<project name="DBBackup" default="RemoveOldBackups" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env" />
<property file="backup.properties" />
<tstamp />
<condition property="Build.Verbose">
<contains substring="-v" string="${sun.java.command}"/>
</condition>
<condition property="Build.Verbose" value="false">
<not>
<isset property="Build.Verbose"/>
</not>
</condition>
<!--* Generate a random UUID*-->
<scriptdef language="javascript" name="generateguid">
<attribute name="property"/>
<![CDATA[
project.setProperty( attributes.get( "property" ), java.util.UUID.randomUUID() );
]]>
</scriptdef>
<!--* Determine current hostname*-->
<exec outputproperty="LocalHost" executable="hostname"/>
<!--* Determine Operating System*-->
<condition property="OperatingSystem" value="Windows">
<os family="windows"/>
</condition>
<condition property="OperatingSystem" value="UNIX">
<os family="unix"/>
</condition>
<property name="OperatingSystem" value="Other"/>
<!--* Not necessary, but useful for Problem Determination*-->
<target name="BOM">
<generateguid property="whoami.guid"/>
<tempfile property="whoami.file" destDir="${Temp.Directory}" prefix="whoami.${whoami.guid}."/>
<exec dir="${Temp.Directory}" executable="whoami" failonerror="false" resultproperty="whoami.result" output="${whoami.file}"> </exec>
<loadfile property="whoami.output" srcfile="${whoami.file}"/>
<delete file="${whoami.file}" verbose="false"/>
<echo message="###########################################################################################################"/>
<echo message="########## START - BOM - Bill Of Materials ##########"/>
<echo message="###########################################################################################################"/>
<echo message="###### Build started by = ${whoami.output}"/>
<echo message="###### Machine name = ${LocalHost}"/>
<echo message="###### Operating System = ${OperatingSystem}"/>
<echo message="###### JAVA_HOME = ${env.JAVA_HOME}"/>
<echo message="###### ANT_HOME = ${env.ANT_HOME}"/>
<echo message="###### Ant version = ${ant.version}"/>
<echo message="###### basedir = ${basedir}"/>
<echo message="###### Verbose mode = ${Build.Verbose}"/>
<echo message="###########################################################################################################"/>
<echo message="########## Properties Values ##########"/>
<echo message="###########################################################################################################"/>
<echo message="###### dlc_home = ${progress.DLC}"/>
<echo message="###### Online Backup = ${backup.online}"/>
<echo message="###### Parallel = ${parallel}"/>
<echo message="###### threadCount = ${threadCount}"/>
<echo message="###### Temp Directory = ${Temp.Directory}"/>
<echo message="###### Database List = ${Database.List}"/>
<echo message="###########################################################################################################"/>
<echo message="########## END - BOM - Bill Of Materials ##########"/>
<echo message="###########################################################################################################"/>
</target>
<target name="BackupDatabases" depends="BOM">
<for list="${Database.List}" param="database" parallel="${parallel}" threadCount="${threadCount}">
<sequential>
<echo message="Working on Database: @{database} Full path: ${Database.List.@{database}.Location}${Database.List.@{database}.FileName}" />
<if> <equals arg1="${backup.online}" arg2="online" />
<then>
<exec executable="${progress.DLC}/bin/_mprshut" failonerror="true" dir="${Database.List.@{database}.Location}">
<arg line="${Database.List.@{database}.FileName} -C backup online ${Database.List.@{database}.LocalBackup}${DSTAMP}${Database.List.@{database}.BackupFile} -com -Bp ${Private.Buffers}" />
</exec>
</then>
<else>
<exec executable="${progress.DLC}/bin/_dbutil" failonerror="true" dir="${Database.List.@{database}.Location}">
<arg line="probkup ${Database.List.@{database}.FileName} ${Database.List.@{database}.LocalBackup}${DSTAMP}${Database.List.@{database}.BackupFile} -com" />
</exec>
</else>
</if>
</sequential>
</for>
</target>
<target name="VerifyBackup" depends="BackupDatabases">
<for list="${Database.List}" param="database" parallel="${parallel}" threadCount="${threadCount}">
<sequential>
<echo message="Working on Database: @{database} Full path: ${Database.List.@{database}.Location}${Database.List.@{database}.FileName}" />
<exec executable="${progress.DLC}/bin/_dbutil" failonerror="true" dir="${Database.List.@{database}.Location}">
<arg line="prorest ${Temp.Directory}/${Database.List.@{database}.FileName} ${Database.List.@{database}.LocalBackup}${DSTAMP}${Database.List.@{database}.BackupFile} -vp" />
</exec>
</sequential>
</for>
</target>
<target name="CopyOffsite" depends="VerifyBackup">
<for list="${Database.List}" param="database" parallel="${parallel}" threadCount="${threadCount}">
<sequential>
<echo message="Working on Database: @{database} Full path: ${Database.List.@{database}.Location}${Database.List.@{database}.FileName}" />
<copy file="${Database.List.@{database}.LocalBackup}${DSTAMP}${Database.List.@{database}.BackupFile}"
todir="${Database.List.@{database}.OffsiteBackup}"
failonerror="true"/>
</sequential>
</for>
</target>
<target name="BackupConfig" depends="CopyOffsite">
<for list="${Database.List}" param="database" parallel="${parallel}" threadCount="${threadCount}">
<sequential>
<echo message="Working on Database: @{database} Full path: ${Database.List.@{database}.Location}${Database.List.@{database}.FileName}" />
<for list="${Database.List.@{database}.ConfigFiles}" param="filename" parallel="${parallel}" threadCount="${threadCount}">
<sequential>
<copy file="@{filename}"
todir="${Database.List.@{database}.LocalBackup}"
failonerror="true" />
<copy file="@{filename}"
todir="${Database.List.@{database}.OffsiteBackup}"
failonerror="true" />
</sequential>
</for>
</sequential>
</for>
</target>
<target name="CopyAIOffsite" depends="BackupConfig">
<for list="${Database.List}" param="database" parallel="${parallel}" threadCount="${threadCount}">
<sequential>
<copy todir="${Database.List.@{database}.OffsiteAIBackup}" failonerror="true">
<fileset dir="${Database.List.@{database}.AIArchive}"/>
</copy>
</sequential>
</for>
</target>
<target name="CleanupAI" depends="CopyAIOffsite">
<for list="${Database.List}" param="database" parallel="${parallel}" threadCount="${threadCount}">
<sequential>
<echo message="Working on Database: @{database} Full path: ${Database.List.@{database}.Location}${Database.List.@{database}.FileName}" />
<tstamp>
<format property="AIRetention" pattern="MM/dd/yyyy hh:mm a" locale="en,UK" offset="-${AI.Retention.Number}" unit="${AI.Retention.Unit}"/>
</tstamp>
<delete>
<fileset dir="${Database.List.@{database}.AIArchive}" includes="**/*.*">
<date datetime="${AIRetention}" when="before"/>
</fileset>
</delete>
</sequential>
</for>
</target>
<target name="RemoveOldBackups" depends="BackupDatabases,VerifyBackup,CopyOffsite,BackupConfig,CopyAIOffsite,CleanupAI">
<for list="${Database.List}" param="database" parallel="${parallel}" threadCount="${threadCount}">
<sequential>
<echo message="Working on Database: @{database} Full path: ${Database.List.@{database}.Location}${Database.List.@{database}.FileName}" />
<tstamp>
<format property="BKRetention" pattern="MM/dd/yyyy hh:mm a" locale="en,UK" offset="-${Backup.Retention.Number}" unit="${Backup.Retention.Unit}"/>
</tstamp>
<delete>
<fileset dir="${Database.List.@{database}.LocalBackup}" includes="**/*.bkp">
<date datetime="${BKRetention}" when="before"/>
</fileset>
</delete>
</sequential>
</for>
</target>
</project>