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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI01-discovery/branches/ingestAutomation-upgrade/exist_backup.py@3815
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.

Line 
1#!/usr/bin/python
2#
3# Usage: exist_backup <database> <target directory>
4#
5# Uses  backup.sh client with the -d dump option 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# On glue this is normally run as user exist
10#
11# History:
12#
13#   27/02/06 SEL First version
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.
17#   12/05/06 SEL spelling correction
18#   18/05/06 SEL Don't echo the password
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.
22#
23import sys
24import os
25import commands
26
27status = 0
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')
31
32#TMP_DIR = '/usr/local/exist/backup'
33
34# replace glue.badc.rl.ac.uk with actual location if different eg. machine.ac.uk or localhost
35if (len(sys.argv) < 3):
36    print "<database> and <target_directory> parameters not supplied - will use defaults"
37    database = 'xmldb:exist://glue.badc.rl.ac.uk:8080/exist/xmlrpc'
38    target_directory = '/disks/glue1/existBackup/dev/data'
39else:
40    database  = sys.argv[1]
41    target_directory = sys.argv[2]
42
43os.chdir('/usr/local/exist-client')
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
49cmd = "/usr/local/exist-client/bin/backup.sh -d " + backup_directory + " -u admin -p xxxxxxx -b /db -ouri=" + database
50print "Executing: the actual backup command"
51status = os.system (cmd)
52if status != 0:
53    sys.exit('FAILED when running the backup command backup.sh. Status = %s' %status)
54
55#cmd = "mkdir " + backup_directory
56#print "Executing: ", cmd
57#status = os.system (cmd)
58
59#cmd = "cp -R " + TMP_DIR + "/* " + backup_directory
60#print "Executing: ", cmd
61#status = os.system (cmd)
62
63print "eXist_backup script completed " + commands.getoutput ("date +'%y%m%d_%H%M'")
Note: See TracBrowser for help on using the repository browser.