forked from GsDevKit/gsDevKitHome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstoneNewExtent
executable file
·114 lines (89 loc) · 3.91 KB
/
stoneNewExtent
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#! /bin/bash
#=========================================================================
# Copyright (c) 2014, 2015 GemTalk Systems, LLC <[email protected]>.
#=========================================================================
echo "================="
echo " GsDevKit script: $(basename $0) $*"
echo "================="
usage() {
cat <<HELP
USAGE: $(basename $0) [-h] [-n] [-s <snapshot-file-path>] <stone-name>
Copy a new extent into the stone's extent directory. The stone
will be stopped before doing the copy and after the copy is complete,
the stone will be restarted with the -N option.
If the -s option is not specified, $GEMSTONE/bin/extent0.seaside.dbf will be used as
the initial extent.
If the -n option is not specified, the tranlogs in the stone's tranlog directory will
be removed before the stone is restarted.
With the -n option, the stone is not restarted, the <snapshot-file-path> is required
and tranlogs are not removed
Please read the 'How to Restore from Backup' section of the System Administration manual
(http://downloads.gemtalksystems.com/docs/GemStone64/3.2.x/GS64-SysAdmin-3.2/GS64-SysAdmin-3.2.htm?http://downloads.gemtalksystems.com/docs/GemStone64/3.2.x/GS64-SysAdmin-3.2/9-BackupAndRestore.htm#pgfId-999128)
before using the -n option.
OPTIONS
-h
display help
-n
No startStone. <snapshot-file-path> required. Please read the 'How to Restore from
Backup' section of the System Administration manual
(http://downloads.gemtalksystems.com/docs/GemStone64/3.2.x/GS64-SysAdmin-3.2/GS64-SysAdmin-3.2.htm?http://downloads.gemtalksystems.com/docs/GemStone64/3.2.x/GS64-SysAdmin-3.2/9-BackupAndRestore.htm#pgfId-999128)
before using the -n option.
-s <snapshot-file-path>
Path to snapshot file used to create stone. Path may be a relative file path.
EXAMPLES
$(basename $0) -h
$(basename $0) kit
$(basename $0) -s $GS_HOME/gemstone/snapshots/extent0.tode.3.2.4.dbf kit
HELP
}
set -e # exit on error
if [ "${GS_HOME}x" = "x" ] ; then
echo "the GS_HOME environment variable needs to be defined"; exit 1
fi
snapshotFile=""
noRestart="false"
while getopts "hns:" OPT ; do
case "$OPT" in
h) usage; exit 0;;
n) noRestart="true";;
s) snapshotFile=`readlink -f ${OPTARG}` ;;
*) usage; exit 1;;
esac
done
shift $(($OPTIND - 1))
if [ $# -ne 1 ]; then
usage; exit 1
fi
stoneName=$1
# set up stone environment
stonePath=$GS_HOME/gemstone/stones/$stoneName
if [ ! -e "$stonePath/stone.env" ] ; then
echo "The file: $stonePath/stone.env is missing ... $stonePath directory appears to be corrupted."
fi
pushd $stonePath >& /dev/null
source $stonePath/stone.env
popd >& /dev/null
echo "Shutdown stone"
$GS_HOME/bin/stopStone $stoneName
if [ "${noRestart}" = "false" ] ; then
echo "Copy snapshot and remove tranlogs"
$GS_HOME/bin/tode newExtent $stoneName $snapshotFile
# -N option used to ignore tranlog files during restart
echo "Restarting stone"
$GS_HOME/bin/startStone -N $stoneName
else
echo "Copy snapshot and leave tranlogs for recovery"
if [ "${snapshotFile}x" = "x" ] ; then
echo "Must specify <snapshot-file-path>, when using the -n (no restart option)"
echo " Tranlogs left in $GS_HOME/gemstone/stones/${stoneName}/tranlogs"
echo " Are not likely to be appropriate for $GEMSTONE/bin/extent0.seaside.dbf"
usage; exit 1
fi
$GS_HOME/bin/tode newExtentForRecovery $stoneName $snapshotFile
echo "Stone is now ready for recovery. Please read the How to Restore from Backup"
echo "section of the manual (http://downloads.gemtalksystems.com/docs/GemStone64/3.2.x/GS64-SysAdmin-3.2/GS64-SysAdmin-3.2.htm?http://downloads.gemtalksystems.com/docs/GemStone64/3.2.x/GS64-SysAdmin-3.2/9-BackupAndRestore.htm#pgfId-999128)"
echo ""
echo "In the simplest case you can just use the '$GS_HOME/startGemstone $stoneName'"
echo "and the system will automatically recover from the tranlogs in the stone's "
echo "tranlog directory/"
fi