root/trunk/deployment/dumprestore/shellscr/resources/dumpres.sh

Revision 1286 (checked in by douglm, 6 years ago)

Mostly changes to support Oracle along with other db systems.

Constraints are now all named, indexes are all named, names follow a consistent pattern (I hope).

Also some fixes to caldav

Line 
1 #!/bin/sh
2
3 # Run the bedework dump/restore program
4 # First arg defines the action, dump, restore etc
5 # Second arg should be the filename
6
7 # JAVA_HOME needs to be defined
8
9 cp=@CP@
10
11 DUMPCMD="$JAVA_HOME/bin/java -cp $cp @DUMP-CLASS@"
12 RESTORECMD="$JAVA_HOME/bin/java -cp $cp @RESTORE-CLASS@"
13 SCHEMACMD="$JAVA_HOME/bin/java -cp $cp org.hibernate.tool.hbm2ddl.SchemaExport"
14
15 APPNAME=@BW-APP-NAME@
16
17 case "$1" in
18   dump)
19     echo $DUMPCMD -appname $APPNAME -f $2 $3 $4 $5 $6 $7 $8 $9
20     $DUMPCMD -appname $APPNAME -f $2 $3 $4 $5 $6 $7 $8 $9
21     ;;
22   restore)
23     echo $RESTORECMD -appname $APPNAME -f $2 $3 $4 $5 $6 $7 $8 $9
24     $RESTORECMD -appname $APPNAME -f $2 $3 $4 $5 $6 $7 $8 $9
25     ;;
26   restore-for-quickstart)
27     echo $RESTORECMD -appname $APPNAME -onlyusers "public-user,caladmin,douglm,agrp_*" -f $2 $3 $4 $5 $6 $7 $8 $9
28     $RESTORECMD -appname $APPNAME -onlyusers "public-user,caladmin,douglm,agrp_*" -f $2 $3 $4 $5 $6 $7 $8 $9
29     ;;
30   backup)
31     TARGET=$2/$3`date +%Y%m%d_%H%M%S`.xml
32     echo $DUMPCMD -appname $APPNAME -f $TARGET
33     $DUMPCMD -appname $APPNAME -f $TARGET
34     ;;
35   initdb)
36     echo $RESTORECMD -appname $APPNAME -f ./data/initbedework.xml -initSyspars $2 $3 $4 $5 $6 $7 $8 $9
37     $RESTORECMD -appname $APPNAME -f ./data/initbedework.xml -initSyspars $2 $3 $4 $5 $6 $7 $8 $9
38     ;;
39   drop)
40     echo $SCHEMACMD --text --drop --format --delimiter="@SCHEMA-DELIMITER@" --config=./classes/hibernate.cfg.xml --output=schema.sql
41     $SCHEMACMD --text --drop --format --delimiter="@SCHEMA-DELIMITER@" --config=./classes/hibernate.cfg.xml --output=schema.sql
42     ;;
43   drop-export)
44     echo $SCHEMACMD --drop --format --delimiter="@SCHEMA-DELIMITER@" --config=./classes/hibernate.cfg.xml --output=schema.sql $2 $3 $4 $5 $6 $7 $8 $9
45     $SCHEMACMD --drop --format --delimiter="@SCHEMA-DELIMITER@" --config=./classes/hibernate.cfg.xml --output=schema.sql $2 $3 $4 $5 $6 $7 $8 $9
46     ;;
47   schema)
48     echo $SCHEMACMD --text --create --format --delimiter="@SCHEMA-DELIMITER@" --config=./classes/hibernate.cfg.xml --output=schema.sql
49     $SCHEMACMD --text --create --format --delimiter="@SCHEMA-DELIMITER@" --config=./classes/hibernate.cfg.xml --output=schema.sql
50     ;;
51   schema-export)
52     echo $SCHEMACMD --create --format --delimiter="@SCHEMA-DELIMITER@" --config=./classes/hibernate.cfg.xml --output=schema.sql $2 $3 $4 $5 $6 $7 $8 $9
53     $SCHEMACMD --create --format --delimiter="@SCHEMA-DELIMITER@" --config=./classes/hibernate.cfg.xml --output=schema.sql $2 $3 $4 $5 $6 $7 $8 $9
54     ;;
55   *)
56     echo $" "
57     echo $"Usage: "
58     echo $"  $0 dump <filename> "
59     echo $"     Dump the database in xml format suitable for restore."
60     echo $" "
61     echo $"  $0 restore <filename> "
62     echo $"     Restore the database from an xml formatted dump."
63     echo $" "
64     echo $"  $0 backup <directory> <prefix>} "
65     echo $"     Dump the database in xml format suitable for restore."
66     echo $"     Files will have a name built from the prefix and the current date/time."
67     echo $" "
68     echo $"  $0 initdb [--indexroot=<lucene-index-root>"
69     echo $"     Populate the database using the provided initial data."
70     echo $" "
71     echo $"  $0 drop [--haltonerror] "
72     echo $"     Create a file in the current directory with sql drop statements"
73     echo $" "
74     echo $"  $0 drop-export [--haltonerror]"
75     echo $"     Drop tables in the database. Note this may not work if the schema"
76     echo $"     was changed."
77     echo $" "
78     echo $"  $0 schema [--haltonerror] "
79     echo $"     Create a schema from the xml schema. Placed in a file in the current directory"
80     echo $" "
81     echo $"  $0 schema-export [--haltonerror]"
82     echo $"     Create a schema from the xml schema."
83     echo $"     Also create the database tables, indexes etc."
84     echo $" "
85 esac
86
Note: See TracBrowser for help on using the browser.