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

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

Changes for upgrade and re-deployment of eXist db in slightly different manner.

RevLine 
[720]1#!/usr/bin/python
2#
3# Usage: exist_backup <database> <target directory>
4#
[1579]5# Uses  backup.sh client with the -d dump option to dump the  database to disc.
[720]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# On glue this is normally run as user exist
10#
11# History:
12#
13#   27/02/06 SEL First version
[909]14#   10/05/06 SEL Had to add password as one has now been set.
15#                Note password is not actually in this public version.
16#                Have to change xxxxx to actual in production version.
[956]17#   12/05/06 SEL spelling correction
18#   18/05/06 SEL Don't echo the password
[1579]19#   27/09/06 SEL The eXist db has been deployed differently. The database resides in the usual
20#                tomcat webapps directory, but the admin client has also been installed at
21#                /usr/local/exist-client for doing command-line backups etc.
[720]22#
23import sys
24import os
25import commands
26
27status = 0
[1579]28os.putenv ('PATH', '/usr/local/exist-client/bin:/bin:/usr/bin:.')
29os.putenv ('JAVA_HOME', '/usr/java/jdk1.5.0_03')
30os.putenv ('EXIST_HOME', '/usr/local/exist-client')
[720]31
[1579]32#TMP_DIR = '/usr/local/exist/backup'
[720]33
[1579]34# replace glue.badc.rl.ac.uk with actual location if different eg. machine.ac.uk or localhost
[720]35if (len(sys.argv) < 3):
36    print "<database> and <target_directory> parameters not supplied - will use defaults"
[1579]37    database = 'xmldb:exist://glue.badc.rl.ac.uk:8080/exist/xmlrpc'
[720]38    target_directory = '/disks/glue1/existBackup/dev/data'
39else:
40    database  = sys.argv[1]
41    target_directory = sys.argv[2]
42
[1579]43os.chdir('/usr/local/exist-client')
[720]44
45date_string = commands.getoutput ("date +'%y%m%d_%H%M'")
46backup_directory = target_directory + '/eXist_daily_' + date_string
47print " Backup directory: ", backup_directory
48
[1579]49cmd = "/usr/local/exist-client/bin/backup.sh -d " + backup_directory + " -u admin -p xxxxxxx -b /db -ouri=" + database
[956]50print "Executing: the actual backup command"
[720]51status = os.system (cmd)
52if status != 0:
[1579]53    sys.exit('FAILED when running the backup command backup.sh. Status = %s' %status)
[720]54
[1579]55#cmd = "mkdir " + backup_directory
56#print "Executing: ", cmd
57#status = os.system (cmd)
[720]58
[1579]59#cmd = "cp -R " + TMP_DIR + "/* " + backup_directory
60#print "Executing: ", cmd
61#status = os.system (cmd)
[720]62
63print "eXist_backup script completed " + commands.getoutput ("date +'%y%m%d_%H%M'")
Note: See TracBrowser for help on using the repository browser.