Changeset 3804 for TI01-discovery/trunk


Ignore:
Timestamp:
18/04/08 16:37:23 (11 years ago)
Author:
selatham
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI01-discovery/trunk/ingestAutomation/exist_backup.py

    r1579 r3804  
    11#!/usr/bin/python 
    22# 
    3 # Usage: exist_backup <database> <target directory> 
     3# Usage: exist_backup <database> <target directory> <java home location> 
    44# 
    5 # Uses  backup.sh client with the -d dump option to dump the  database to disc. 
     5# Uses  the backup class in the java webapp to dump the  database to disc. 
    66# The directory tree of dumped files is put in 
    77# the target directory and is named using the current date and time. 
    88# 
    9 # On glue this is normally run as user exist 
     9# Script normally run as user badc 
    1010# 
    1111# History: 
    1212# 
    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 # 
     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#    
    2316import sys 
    2417import os 
     
    2619 
    2720status = 0 
    28 os.putenv ('PATH', '/usr/local/exist-client/bin:/bin:/usr/bin:.') 
    29 os.putenv ('JAVA_HOME', '/usr/java/jdk1.5.0_03') 
    30 os.putenv ('EXIST_HOME', '/usr/local/exist-client') 
    3121 
    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 
    35 if (len(sys.argv) < 3): 
     22# replace default db with actual location if different eg. machine.ac.uk or localhost 
     23if (len(sys.argv) < 4): 
    3624    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' 
     25    database = 'xmldb:exist://proglue.badc.rl.ac.uk:8080/exist/xmlrpc' 
     26    target_directory = '/usr/local/backups/exist' 
     27    java_home = 'java' 
    3928else: 
    4029    database  = sys.argv[1] 
    4130    target_directory = sys.argv[2] 
    42  
    43 os.chdir('/usr/local/exist-client') 
     31    java_home = sys.argv[3] 
    4432 
    4533date_string = commands.getoutput ("date +'%y%m%d_%H%M'") 
     
    4735print " Backup directory: ", backup_directory 
    4836 
    49 cmd = "/usr/local/exist-client/bin/backup.sh -d " + backup_directory + " -u admin -p xxxxxxx -b /db -ouri=" + database 
     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 
    5038print "Executing: the actual backup command" 
    5139status = os.system (cmd) 
    5240if status != 0: 
    53     sys.exit('FAILED when running the backup command backup.sh. Status = %s' %status) 
     41    sys.exit('FAILED when running the backup command. Status = %s' %status) 
    5442 
    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  
    63 print "eXist_backup script completed " + commands.getoutput ("date +'%y%m%d_%H%M'") 
     43print "eXist_backup.py script completed " + commands.getoutput ("date +'%y%m%d_%H%M'") 
Note: See TracChangeset for help on using the changeset viewer.