I know there are already a good number of blogs/guides out there already describing various methods of automating the backup of APEX applications, however I thought I'd share the method I recently implemented internally as it uses a remote subversion repository. This gives rise to a number of subsequent benefits such as holding a full version history, low storage overheads and resilience to local hardware failure. Why might you want to do this? Well, aside from the obvious catastrophes, acts of God, malicious deletion, accidental corruption etc, it's sometimes simply useful to be able to take your application as of a particular point in time, regardless of your database flashback etc.
Anyway, here is the process we take will follow.
- Export all our APEX applications from the workspace.
- Add any new applications that we've not seen before to the svn repository.
- Commit any changes to svn
First we need to create a working directory of our repository on the APEX database server. Note that I already added all applications to this repository previously - this is not necessary however. I chose to check out a specific directory only rather than the root. You of course need to install the svn client software on your server if you haven't already for this step. It's free and easy - and not worth explaining here.
[oracle@localhost tmp]$ svn checkout https://mysvnrepo/folder/subfolder/etc svn A svn/f101.sql A svn/f10100.sql A svn/f110.sql A svn/f10200.sql A svn/f20100.sql A svn/f10210.sql A svn/f20200.sql A svn/f20300.sql Checked out revision 1079.
To export we can use the
APEXExport Java utility. This is called in the following way.
java -cp $CLASSPATH oracle.apex.APEXExport -db <database connection> -user <database user> -password <database password> -workspaceid <workspace id>
This will generate a set of .sql files in the format f<application_id>.sql in the current directory, which we can then copy into our working directory. The issue here is that an APEX export file contains a line representing the date and time at which the export was done. This will then be considered a change by svn. To avoid that, I strip out that line using the
sed -i '/-- Date and Time:/d' f*.sql