source: TI01-discovery/tags/stable-TI01-ingestAutomation-ALPHA/exist_backup.py @ 962

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI01-discovery/tags/stable-TI01-ingestAutomation-ALPHA/exist_backup.py
Revision 962, 1.9 KB checked in by selatham, 14 years ago (diff)

typing error in options

Line 
1#!/usr/bin/python
2#
3# Usage: exist_backup <database> <target directory>
4#
5# Uses  backup_ndg.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#
20import sys
21import os
22import commands
23
24status = 0
25os.putenv ('PATH', '/usr/local/eXist/bin:/bin:/usr/bin:.')
26os.putenv ('EXIST_HOME', '/usr/local/eXist')
27
28TMP_DIR = '/usr/local/eXist/backup'
29
30if (len(sys.argv) < 3):
31    print "<database> and <target_directory> parameters not supplied - will use defaults"
32    database = 'xmldb:exist://localhost:8080/exist/xmlrpc'
33    target_directory = '/disks/glue1/existBackup/dev/data'
34else:
35    database  = sys.argv[1]
36    target_directory = sys.argv[2]
37
38os.chdir('/usr/local/eXist')
39
40date_string = commands.getoutput ("date +'%y%m%d_%H%M'")
41backup_directory = target_directory + '/eXist_daily_' + date_string
42print " Backup directory: ", backup_directory
43
44cmd = "/usr/local/eXist/bin/backup_ndg.sh -d /usr/local/eXist/backup -u admin -p xxxxxxx -b /db -ouri=" + database
45print "Executing: the actual backup command"
46status = os.system (cmd)
47if status != 0:
48    sys.exit('FAILED when running the backup command backup_ndg.sh. Status = %s' %status)
49
50cmd = "mkdir " + backup_directory
51print "Executing: ", cmd
52status = os.system (cmd)
53
54cmd = "cp -R " + TMP_DIR + "/* " + backup_directory
55print "Executing: ", cmd
56status = os.system (cmd)
57
58print "eXist_backup script completed " + commands.getoutput ("date +'%y%m%d_%H%M'")
Note: See TracBrowser for help on using the repository browser.