source: TI01-discovery/trunk/ingestAutomation/exist_backup.py @ 3804

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI01-discovery/trunk/ingestAutomation/exist_backup.py
Revision 3804, 1.6 KB checked in by selatham, 12 years ago (diff)

Use the exist interface that comes with .war rather than the old-hat exist-client.

Line 
1#!/usr/bin/python
2#
3# Usage: exist_backup <database> <target directory> <java home location>
4#
5# Uses  the backup class in the java webapp to dump the  database to disc.
6# The directory tree of dumped files is put in
7# the target directory and is named using the current date and time.
8#
9# Script normally run as user badc
10#
11# History:
12#
13#   Completely re-written to use the tomcat webapps version of exist rather than
14#    the shell script supplied only with the source version.
15#   
16import sys
17import os
18import commands
19
20status = 0
21
22# replace default db with actual location if different eg. machine.ac.uk or localhost
23if (len(sys.argv) < 4):
24    print "<database> and <target_directory> parameters not supplied - will use defaults"
25    database = 'xmldb:exist://proglue.badc.rl.ac.uk:8080/exist/xmlrpc'
26    target_directory = '/usr/local/backups/exist'
27    java_home = 'java'
28else:
29    database  = sys.argv[1]
30    target_directory = sys.argv[2]
31    java_home = sys.argv[3]
32
33date_string = commands.getoutput ("date +'%y%m%d_%H%M'")
34backup_directory = target_directory + '/eXist_daily_' + date_string
35print " Backup directory: ", backup_directory
36
37cmd = java_home +" -jar -Dexist.home=/usr/local/tomcat/webapps/exist/WEB-INF /usr/local/tomcat/webapps/exist/WEB-INF/lib/start.jar backup -u admin -p '********' -b /db -d " + backup_directory + " -ouri=" + database
38print "Executing: the actual backup command"
39status = os.system (cmd)
40if status != 0:
41    sys.exit('FAILED when running the backup command. Status = %s' %status)
42
43print "eXist_backup.py script completed " + commands.getoutput ("date +'%y%m%d_%H%M'")
Note: See TracBrowser for help on using the repository browser.