forked from bolthole/zrep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzrep_top
186 lines (171 loc) · 4.09 KB
/
zrep_top
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/ksh -p
# For more detailed documentation, see zrep.txt or zrep.overview.txt
ZREP_VERSION=1.7.3
######## start of included files from zrep_top here
AWKinclude zrep_vars
AWKinclude zrep_status
AWKinclude zrep_snap
AWKinclude zrep_sync
AWKinclude zrep_failover
######## zrep_top continues here
usage(){
print zrep v${ZREP_VERSION}: a program to replicate a zfs filesystem to another
print in an ongoing basis.
print ""
print " Philip Brown, 2012-2017"
print ""
print Simple usage summary:
print 'zrep (init|-i) ZFS/fs remotehost remoteZFSpool/fs'
print 'zrep (sync|-S) [-q seconds] ZFS/fs'
print 'zrep (sync|-S) [-q seconds] all'
print 'zrep (sync|-S) ZFS/fs@snapshot -- temporary retroactive sync'
print 'zrep (status|-s) [-v] [(-a|ZFS/fs)]'
print 'zrep refresh ZFS/fs -- pull version of sync'
print 'zrep (list|-l) [-Lv] [fs/names]'
print 'zrep (list|-l) -s [fs/names] -- list snapshots'
print 'zrep (expire|-e) [-L] (ZFS/fs ...)|(all)|()'
print 'zrep (changeconfig|-C) [-f] ZFS/fs remotehost remoteZFSpool/fs'
print 'zrep (changeconfig|-C) [-f] [-d] ZFS/fs srchost srcZFSpool/fs'
print 'zrep failover [-L] ZFS/fs'
print 'zrep takeover [-L] ZFS/fs'
print 'zrep version'
print 'zrep clear [-f] ZFS/fs -- REMOVE ZREP CONFIG AND SNAPS FROM FILESYSTEM'
print
print ' -q option says to Quietly ignore locked filesystems that have synced'
print ' more recently than the given amount of seconds'
print
print 'Paired commands for high-transaction systems:'
print ' zrep snaponly ZFS/fs'
print ' zrep synconly ZFS/fs'
print 'The above two commands split the simple sync subcommand, into two'
print 'separate steps, so that a database, etc. may resume while the sync'
print 'completes in the background'
print ''
print 'zrep defaults to using ssh. However, if remotehost is set to localhost,'
print 'zrep will use a simple pipe instead.'
print ''
print ' More detailed examples can be found at:'
print http://www.bolthole.com/solaris/zrep/zrep.documentation.html
print ''
print 'See the above documentation for details on using the -t flag'
}
#
# Special global flags that must always be processed FIRST, before normal command args.
#
while [[ "$1" == -[tD] ]] ; do
case "$1" in
-D)
DEBUG=1
shift
;;
-t)
if [ "$2" == "" ] ; then
usage
fi
#deliberately dont quote this to avoid stupidity or malice by user
ZREPTAG=$2
shift
shift
;;
esac
done
if [[ "$ZREPTAG" != "zrep" ]] ; then
# If custom zrep tag, then probably multiple layers of snapshots.
# In this case, DO NOT send all intermediate snapshots for replication
ZREP_INC_FLAG=${ZREP_INC_FLAG:-"-i"}
if [ "$ZREPTAG" != "" ] ; then
ZREP_PATH="$ZREP_PATH -t $ZREPTAG"
fi
fi
# ensure it is set to SOMETHING by default. Default is to send all
ZREP_INC_FLAG=${ZREP_INC_FLAG:-"-I"}
case "$1" in
"")
usage
;;
changeconfig|-C)
shift
zrep_changeconfig "$@"
;;
clear)
shift
# only actually allows ONE fs
if [[ "$1" == "-f" ]] ; then
shift
ZREP_FORCE=-f
fi
zrep_clear "$@"
;;
expire|-e)
shift
zrep_expire "$@"
;;
init|-i)
shift
zrep_init "$@"
;;
sentsync)
shift
# Note that this will NOT accept multiple snaps, for safety
zrep_sentsync "$@"
;;
snaponly)
shift
zrep_snaponly "$@"
;;
sync|-S) #remember, this is inverse of refresh
shift
if [[ "$1" == "-f" ]] ; then
shift
ZREP_FORCE=-f
fi
zrep_sync "$@"
;;
synconly)
shift
zrep_synconly "$@"
;;
refresh) # yes keep this in this order
shift
if [[ "$1" == "-f" ]] ; then
shift
ZREP_FORCE=-f
fi
zrep_refresh "$@"
;;
status|-s)
shift
zrep_status "$@"
;;
list|-l)
shift
zrep_list "$@"
;;
failover)
shift
if [[ "$1" == "-f" ]] ; then
shift
ZREP_FORCE=-f
fi
zrep_failover "$@"
;;
takeover)
shift
zrep_takeover "$@"
;;
version)
print "zrep $ZREP_VERSION"
print "http://www.bolthole.com/solaris/zrep"
print "http://www.github.com/bolthole/zrep"
exit
;;
_refreshpull) # Secret option DO NOT PUT IN USAGE!!
shift
_refreshpull $1
;;
*)
print "ERROR: Dont know what to do with: $@"
print ""
usage
;;
esac