forked from alestic/ec2-consistent-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
310 lines (241 loc) · 11.4 KB
/
README.txt
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
NAME
ec2-consistent-snapshot - Create EBS snapshots on EC2 w/consistent
filesystem/db
SYNOPSIS
ec2-consistent-snapshot [opts] VOLUMEID...
OPTIONS
-h --help
Print help and exit.
-d --debug
Debug mode.
-q --quiet
Quiet mode.
-n --noaction
Don't do it. Just say what you would have done.
--aws-access-key-id KEY
--aws-secret-access-key SECRET
Amazon AWS access key and secret access key. Defaults to environment
variables or .awssecret file contents described below.
--aws-access-key-id-file KEYFILE
--aws-secret-access-key-file SECRETFILE
Files containing Amazon AWS access key and secret access key.
Defaults to environment variables or .awssecret file contents
described below.
--aws-credentials-file CREDENTIALSFILE
File containing both the Amazon AWS access key and secret access key
on seprate lines and in that order. Defaults to contents of
$AWS_CREDENTIALS environment variable or the value $HOME/.awssecret
--region REGION
Specify a different EC2 region like "eu-west-1". Defaults to
"us-east-1".
--description DESCRIPTION
Specify a description string for the EBS snapshot. Defaults to the
name of the program.
You may specify this option multiple times if you need to customize
descriptions of multiple volumes snapshots. If specified multiple
times descriptions count has to match volumes count and they will be
applied on the same order.
--freeze-filesystem MOUNTPOINT
--xfs-filesystem MOUNTPOINT [OBSOLESCENT form of the same option]
Indicates that the filesystem at the specified mount point should be
flushed and frozen during the snapshot. Requires the xfs_freeze or
fsfreeze program. Note that xfs_freeze is equivalent to fsfreeze and
works on any filesystems that support freezing, provided the kernel
you are using supports it. (Linux Ext3/4, ReiserFS, JFS, XFS.)
fsfreeze comes with newer versions of util-linux.
You may specify this option multiple times if you need to freeze
multiple filesystems on the the EBS volume(s).
--mongo
Indicates that the volume contains data files for a running Mongo
database, which will be flushed and locked during the snapshot.
--mongo-host HOST
--mongo-port PORT
--mongo-username USER
--mongo-password PASS
Mongo host, port, username, and password used to flush logs if there
is authentication required on the admin database.
--mongo-stop
Indicates that the volume contains data files for a running Mongo
instance. The instance is shutdown before the snapshot is initiated
and restarted afterwards. [EXPERIMENTAL]
--mysql
Indicates that the volume contains data files for a running MySQL
database, which will be flushed and locked during the snapshot.
--mysql-defaults-file FILE
MySQL defaults file, containing host, username and password, this
option will ignore the --mysql-host, --mysql-username,
--mysql-password parameters
--mysql-host HOST
--mysql-socket PATH
--mysql-username USER
--mysql-password PASS
MySQL host, socket path, username, and password used to flush logs
and lock tables. User must have appropriate permissions. Defaults to
$HOME/.my.cnf file contents.
--mysql-master-status-file FILE
Store the MASTER STATUS output in a file on the snapshot. It will be
removed after the EBS snapshot is taken. This option will be ignored
with --mysql-stop
--mysql-stop
Indicates that the volume contains data files for a running MySQL
database. The database is shutdown before the snapshot is initiated
and restarted afterwards. [EXPERIMENTAL]
--snapshot-timeout SECONDS
How many seconds to wait for the snapshot-create to return. Defaults
to 10.0
--lock-timeout SECONDS
How many seconds to wait for a database lock. Defaults to 0.5.
Making this too large can force other processes to wait while this
process waits for a lock. Better to make it small and try lots of
times.
--lock-tries COUNT
How many times to try to get a database lock before failing.
Defaults to 60.
--lock-sleep SECONDS
How many seconds to sleep between database lock tries. Defaults to
5.0.
--pre-freeze-command COMMAND
Command to run after MySQL stop/lock and before filesystem freeze.
--post-thaw-command COMMAND
Command to run immediately after filesystem unfreeze and before
MySQL start/unlock.
ARGUMENTS
VOLUMEID
EBS volume id(s) for which a snapshot is to be created.
DESCRIPTION
This program creates an EBS snapshot for an Amazon EC2 EBS volume. To
help ensure consistent data in the snapshot, it tries to flush and
freeze the filesystem(s) first as well as flushing and locking the
database, if applicable.
Filesystems can be frozen during the snapshot. Prior to Linux kernel
2.6.29, XFS must be used for freezing support. While frozen, a
filesystem will be consistent on disk and all writes will block.
There are a number of timeouts to reduce the risk of interfering with
the normal database operation while improving the chances of getting a
consistent snapshot.
If you have multiple EBS volumes in a RAID configuration, you can
specify all of the volume ids on the command line and it will create
snapshots for each while the filesystem and database are locked. Note
that it is your responsibility to keep track of the resulting snapshot
ids and to figure out how to put these back together when you need to
restore the RAID setup.
If you have multiple EBS volumes which are hosting different file
systems, it might be better to simply run the command once for each
volume id.
EXAMPLES
Snapshot a volume with a frozen filesystem under /vol containing a MySQL
database:
ec2-consistent-snapshot --mysql --freeze-filesystem /vol vol-VOLUMEID
Snapshot a volume mounted with a frozen filesystem on /var/local but
with no MySQL database:
ec2-consistent-snapshot --freeze-filesystem /var/local vol-VOLUMEID
Snapshot four European volumes in a RAID configuration with MySQL,
saving the snapshots with a description marking the current time:
ec2-consistent-snapshot \
--mysql \
--freeze-filesystem /vol \
--region eu-west-1 \
--description "RAID snapshot $(date +'%Y-%m-%d %H:%M:%S')" \
vol-VOL1 vol-VOL2 vol-VOL3 vol-VOL4
Snapshot two volumes with customized descriptions:
ec2-consistent-snapshot \
--description "Description 1st Volume" \
--description "Description 2nd Volume" \
vol-VOL1 vol-VOL2
ENVIRONMENT
$AWS_ACCESS_KEY_ID
Default value for access key. Can be overridden by command line
options.
$AWS_SECRET_ACCESS_KEY
Default value for secret access key. Can be overridden by command
line options.
$AWS_CREDENTIALS
Default value for filename containing both access key and secret
access key on separate lines and in that order. Can be overriden by
the --aws-credentials command line option.
FILES
$HOME/.my.cnf
Default values for MySQL user and password are sought here in the
standard format.
$HOME/.awssecret
Default values for access key and secret access keys are sought
here. Can be overridden by environment variables and command line
options.
INSTALLATION
On most Ubuntu releases, the ec2-consistent-snapshot package can be
installed directly from the Alestic.com PPA using the following
commands:
sudo add-apt-repository ppa:alestic
sudo apt-get update
sudo apt-get install ec2-consistent-snapshot
This program may also require the installation of the Net::Amazon::EC2,
MongoDB::Admin, and Any::Moose Perl packages from CPAN. On Ubuntu 10.04
Lucid and higher, this should happen automatically by the dependency on
the libnet-amazon-ec2-perl package.
On some earlier releases of Ubuntu you can install the required packages
with the following commands:
sudo PERL_MM_USE_DEFAULT=1 cpan Net::Amazon::EC2
sudo PERL_MM_USE_DEFAULT=1 cpan -fi MongoDB MongoDB::Admin
sudo PERL_MM_USE_DEFAULT=1 cpan -fi Any Any::Moose
On Ubuntu 8.04 Hardy, use the following commands instead:
code=$(lsb_release -cs)
echo "deb http://ppa.launchpad.net/alestic/ppa/ubuntu $code main"|
sudo tee /etc/apt/sources.list.d/alestic-ppa.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BE09C571
sudo apt-get update
sudo apt-get install ec2-consistent-snapshot build-essential
sudo cpan Net::Amazon::EC2
sudo cpan MongoDB::Admin
sudo cpan Any::Moose
The default values can be accepted for most of the prompts, though it is
necessary to select a CPAN mirror on Hardy.
SEE ALSO
Amazon EC2
Amazon EC2 EBS (Elastic Block Store)
ec2-create-snapshot
CAVEATS
This program currently supports the MySQL and MongoDB databases. Patches
are welcomed for other databases.
EBS snapshots are a critical part of protecting your valuable data. This
program or the environment in which it is run may contain defects that
cause snapshots to not be created. Please test and check to make sure
that snapshots are getting created for the volumes as you intend.
EBS snapshots cost money to create and to store in your AWS account. Be
aware of and monitor your expenses.
You are responsible for what happens in your EC2 account. This software
is intended, but not guaranteed, to help in that effort.
This program tries hard to figure out some values are for the AWS key
and AWS secret access key. In fact, it tries too hard. This results in
possibly using some credentials it finds that are not the correct ones
you wish to use, especially if you are operating in an environment where
multiple sets of credentials are in use.
BUGS
Please report bugs at https://bugs.launchpad.net/ec2-consistent-snapshot
CREDITS
Thanks to the following for performing tests on early versions,
providing feedback, and patches:
David Erickson
Steve Caldwell
Gryp
Ken Huang
Jefferson Noxon
Bobb Crosbie
Craig Tracey
Diego Salvi
Christian Marquardt
Todd Roman
Eric Lubow
Kevin Lewis
AUTHOR
Eric Hammond <[email protected]>
LICENSE
Copyright 2009-2012 Eric Hammond <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License. You may obtain
a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.