Skip to content

Commit 8624887

Browse files
committed
fix(backup-task): address inconsistencies with configuration
add test close #308 close #437
1 parent 3f8a2dc commit 8624887

File tree

6 files changed

+86
-23
lines changed

6 files changed

+86
-23
lines changed

src/main/xar-resources/data/backup/backup.xml

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<info>
88
<title>Database Backup and Restore</title>
9-
<date>2Q19</date>
9+
<date>1Q20</date>
1010
<keywordset>
1111
<keyword>operations</keyword>
1212
</keywordset>
@@ -159,18 +159,18 @@
159159
the name of an archive to download it.</para>
160160
<para>eXist-db can also create <emphasis>incremental backups</emphasis>, meaning only
161161
resources which were modified since the last backup are backed up.</para>
162-
<para>All backups will be stored in ZIP format. The default storage directory is
162+
<para>The default storage directory is
163163
<literal>$EXIST_HOME/data/export/</literal>. You can configure a different
164164
directory in the configuration file <literal>conf.xml</literal>.</para>
165165
</sect2>
166166

167167
<sect2 xml:id="schedule">
168168
<title>Scheduling Backups</title>
169169

170-
<para>You can use eXist-db's <link xlink:href="configuration">scheduler</link> to
170+
<para>You can use eXist-db's <link xlink:href="configuration#scheduler">scheduler</link> to
171171
schedule server-side backup and consistency check tasks. To do this, add the
172172
following definition to the scheduler section in the configuration file
173-
<literal>$EXIST_HOME/etc/conf.xml</literal></para>
173+
<literal>$EXIST_HOME/etc/conf.xml</literal>.</para>
174174

175175

176176
<example>
@@ -190,7 +190,7 @@
190190
<term>output</term>
191191
<listitem>
192192
<para>The directory to which the backup is written. Relative paths are
193-
interpreted relative to eXist-db's main data directory.</para>
193+
interpreted relative to eXist-db's main data directory <literal>$EXIST_HOME/data</literal>.</para>
194194
</listitem>
195195
</varlistentry>
196196
<varlistentry>
@@ -240,12 +240,44 @@
240240
two incremental backups.</para>
241241
</listitem>
242242
</varlistentry>
243+
<varlistentry>
244+
<!-- or output-dir or output ? -->
245+
<term>dir</term>
246+
<listitem>
247+
<para>The directory to store the backup in. The path is relative to exist's default data directory.</para>
248+
</listitem>
249+
</varlistentry>
250+
<varlistentry>
251+
<term>suffix / prefix</term>
252+
<listitem>
253+
<para>Start and end of the filename for a zipped backup.</para>
254+
</listitem>
255+
</varlistentry>
256+
<varlistentry>
257+
<term>collection</term>
258+
<listitem>
259+
<para>The name of the instances' collection to be included in the backup.</para>
260+
</listitem>
261+
</varlistentry>
262+
<varlistentry>
263+
<term>user / password</term>
264+
<listitem>
265+
<para>The username and password combination necessary for accessing the backup.</para>
266+
</listitem>
267+
</varlistentry>
268+
<varlistentry>
269+
<term>zip-files-max</term>
270+
<listitem>
271+
<para>The maximum number of backups to keep in the backup location.</para>
272+
</listitem>
273+
</varlistentry>
243274
</variablelist>
244275

245276
<note>
246277
<para>You can schedule more than one backup job. For example, an incremental backup
247-
could be done multiple times a day while a full backup is created once during
248-
the night </para>
278+
could be done multiple e.g. every two minutes while a full backup is created once during
279+
the night.</para>
280+
<programlisting language="xml" xlink:href="listings/listing-3.xml"/>
249281
</note>
250282
</sect2>
251283

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<job type="system" class="org.exist.storage.ConsistencyCheckTask" cron-trigger="0 0 0/12 * * ?">
2-
<!-- the output directory. paths are relative to the data dir -->
1+
<job type="system" name="check1" class="org.exist.storage.ConsistencyCheckTask" cron-trigger="0 0 0/12 * * ?">
32
<parameter name="output" value="export"/>
43
<parameter name="zip" value="yes"/>
54
<parameter name="backup" value="yes"/>
6-
<parameter name="incremental" value="yes"/>
5+
<parameter name="incremental" value="no"/>
76
<parameter name="incremental-check" value="no"/>
7+
<parameter name="max" value="2"/>
88
</job>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<job type="system" name="databackup" class="org.exist.storage.DataBackup" period="120000">
2+
<parameter name="output-dir" value="backup"/>
3+
<parameter name="suffix" value=".zip"/>
4+
<parameter name="prefix" value="backup-"/>
5+
<parameter name="collection" value="/db"/>
6+
<parameter name="user" value="admin"/>
7+
<parameter name="password"/>
8+
<parameter name="zip-files-max" value="28"/>
9+
</job>

src/main/xar-resources/data/configuration/configuration.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<para><tag>indexer</tag>: Controls the indexing process.</para>
4545
</listitem>
4646
<listitem>
47-
<para><tag>scheduler</tag>: Job scheduler for system or user jobs.</para>
47+
<para><tag>scheduler</tag>: Job scheduler for system or user jobs such as backups.</para>
4848
</listitem>
4949
<listitem>
5050
<para><tag>parser</tag>: Default settings for parsing structured documents.</para>
@@ -635,7 +635,6 @@
635635
</variablelist>
636636
<para>Below is an example which configures a <link xlink:href="backup"
637637
>BackupSystemTask</link>: </para>
638-
639638
<programlisting language="xml" xlink:href="listings/listing-6.xml"/>
640639
<para>Each job is configured in a <tag>job</tag> element which accepts a number of
641640
standard attributes:</para>
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
<scheduler>
2-
<job type="system" class="org.exist.storage.BackupSystemTask" cron-trigger="0 0 */6 * * ?">
3-
<parameter name="dir" value="backup"/>
4-
<parameter name="suffix" value=".zip"/>
5-
<parameter name="prefix" value="backup-"/>
6-
<parameter name="collection" value="/db"/>
7-
<parameter name="user" value="admin"/>
8-
<parameter name="password"/>
9-
<parameter name="zip-files-max" value="28"/>
10-
</job>
11-
</scheduler>
1+
<job type="system" name="databackup" class="org.exist.storage.DataBackup" period="120000">
2+
<parameter name="output-dir" value="backup"/>
3+
<parameter name="suffix" value=".zip"/>
4+
<parameter name="prefix" value="backup-"/>
5+
<parameter name="collection" value="/db"/>
6+
<parameter name="user" value="admin"/>
7+
<parameter name="password"/>
8+
<parameter name="zip-files-max" value="28"/>
9+
</job>

src/main/xar-resources/modules/test-suite.xql

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ declare variable $tests:article := document {
4747

4848
};
4949

50+
(:~ see if all sections have an ID (now inforced via schema)
51+
: @return empty-sequence otherwise name of document with faulty section
52+
:)
5053
declare
5154
%test:name('section-headings')
5255
%test:assertEmpty
@@ -67,6 +70,9 @@ function tests:missing-id() {
6770
$m
6871
};
6972

73+
(:~ Run the diagnose listings page and see if there are new Errors
74+
: @return empty-sequence, otherwise name of listing and parent collection
75+
:)
7076
declare
7177
%test:name('diagnose listings')
7278
%test:assertEmpty
@@ -84,6 +90,7 @@ function tests:orphan-listing() {
8490
else ()
8591
};
8692

93+
(:~ See if ToC rendering is WAI :)
8794
declare
8895
%test:name('ToC rendering')
8996
%test:assertTrue
@@ -107,3 +114,21 @@ function tests:toc-inline() {
107114
return
108115
docbook:toc-db5($tests:article) eq $output
109116
};
117+
118+
(:~ Check if two listings that should be identical actually are.
119+
: Txt and xml listings cannot be easily displayed via <xref> or xinclude
120+
: so unfortunately this is necessary, to avoid conflicting information.
121+
:
122+
: @see author-reference
123+
: @return true (hopefully)
124+
:)
125+
declare
126+
%test:name('Listing consistency')
127+
%test:args('backup/listings/listing-3.xml.','configuration/listings/listing-6.xml')
128+
%test:assertTrue
129+
function tests:equal-listing($path1 as xs:string, $path2 as xs:string) as xs:boolean {
130+
let $a := $config:data-root || $path1
131+
let $b := $config:data-root || $path2
132+
return
133+
deep-equal(doc($a), doc($b))
134+
};

0 commit comments

Comments
 (0)