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

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

Had to put the -p option in the exist backup now

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