Database Reference
In-Depth Information
Backup and shutdown
This target creates a full backup of your database, zips it, and then shuts down eXist:
<target
name=
"BackupShutdown"
description=
"Back up the full database and shut down"
>
<delete
dir=
"backup"
/>
<mkdir
dir=
"backup"
/>
<xdb:backup
uri=
"${BaseUri}"
user=
"${Username}"
password=
"${Password}"
dir=
"backup"
/>
<zip
destfile=
"backup.zip"
basedir=
"backup"
/>
<delete
dir=
"backup"
/>
<xdb:shutdown
uri=
"${BaseUri}"
user=
"${Username}"
password=
"${Password}"
/>
</target>
From top to bottom, this code does the following:
Makes sure we have an empty
backup
directory by first deleting and then (re)cre‐
ating it.
Makes eXist back up into this directory. If you look inside after the backup you'll
find a directory/file structure much like your database's collection/resource
structure. Added are
__contents__.xml
files that contain important eXist proper‐
ties (like security settings).
Zips this directory into a
backup.zip
file (this is easier to handle, and you can
restore directly from such a ZIP file).
Removes the
backup
directory (since everything is in the ZIP now)
Shuts down eXist.
The preceding example performs a full database backup, but you can just as easily
make partial backups—for instance, from your extremely important project collec‐
tion. Simply have the
uri
attribute point to the right collection, like so:
<xdb:backup
uri=
"${BaseUri}/apps/myimportantproject"
...
Of course, there is also an
xdb:restore
task that lets you restore a backup. This task
can use a backup ZIP file directly (no need to unpack it first).
Create separate backups for all subcollections
The following example shows you how to iterate over lists returned by some of eXist's
Ant tasks using the Ant-Contrib extension. It extends the previous example by not
creating a full backup, but a separate backup of each subcollection of
/db
:
<target
name=
"SeparateBackups"
description=
"Make separate backups of all subcollections of /db"
>
<xdb:list
uri=
"${BaseUri}"
user=
"${Username}"
password=
"${Password}"
Search WWH ::
Custom Search