diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/App/Glacier.pm | 57 | ||||
-rw-r--r-- | lib/App/Glacier/Command/Periodic.pm | 15 | ||||
-rw-r--r-- | lib/App/Glacier/Directory.pm | 2 |
3 files changed, 56 insertions, 18 deletions
diff --git a/lib/App/Glacier.pm b/lib/App/Glacier.pm index fea94d5..2954a23 100644 --- a/lib/App/Glacier.pm +++ b/lib/App/Glacier.pm | |||
@@ -187,6 +187,11 @@ Removes the vault. It must be empty for the command to succeed. | |||
187 | 187 | ||
188 | Synchronizes the local vault directory with its latest inventory. | 188 | Synchronizes the local vault directory with its latest inventory. |
189 | 189 | ||
190 | =head2 glacier periodic | ||
191 | |||
192 | Periodic task for glacier job maintenance. It is recommended to run it | ||
193 | each 4 hours as a cronjob. | ||
194 | |||
190 | =head1 OPTIONS | 195 | =head1 OPTIONS |
191 | 196 | ||
192 | =over 4 | 197 | =over 4 |
@@ -230,10 +235,17 @@ Displays a succint command line usage summary, | |||
230 | 235 | ||
231 | =head1 CONFIGURATION | 236 | =head1 CONFIGURATION |
232 | 237 | ||
233 | Default configuration file is F</etc/glacier.conf>. Its location is | 238 | Default configuration file is F</etc/glacier.conf>. This file is optional. |
234 | overridden by the value of the command line option B<--config-file> (B<-c>) | 239 | If it does not exist, B<glacier> will attempt to start up with default |
235 | and the environment variable B<GLACIER_CONF>. The option takes precedence | 240 | values (optionally modified by the command line options). If you run |
236 | over the variable. | 241 | glacier on a EC2 instance with an associated IAM profile, you can omit |
242 | the configuration file, provided that the profile gives the necessary | ||
243 | permissions on the Glacier storage. Please see | ||
244 | L<https://docs.aws.amazon.com/amazonglacier/latest/dev/access-control-identity-based.html> for details on identity-based policies. | ||
245 | |||
246 | Th configuration file can also be specified using the environment variable | ||
247 | B<GLACIER_CONF>, or from the command line, using the B<--config-file> (B<-c>) | ||
248 | option. If both are used, the option takes precedence over the variable. | ||
237 | 249 | ||
238 | Configuration file consists of statements in the form | 250 | Configuration file consists of statements in the form |
239 | I<variable> B<=> I<value>), grouped into sections. Whitespace is ignored, | 251 | I<variable> B<=> I<value>), grouped into sections. Whitespace is ignored, |
@@ -265,24 +277,28 @@ security reason. | |||
265 | 277 | ||
266 | =item B<region => I<NAME> | 278 | =item B<region => I<NAME> |
267 | 279 | ||
268 | Sets the Amazon region. | 280 | Sets the Amazon region. If this setting is absent, B<glacier> will attempt |
281 | to retrieve the region from the instance store (assuming it is run on an EC2 | ||
282 | AWS instance). | ||
269 | 283 | ||
270 | =back | 284 | =back |
271 | 285 | ||
272 | The preferred way for storing credentials is in the I<credentials file>. This | 286 | If either of B<access> or B<secret> is not supplied, B<glacier> attemtps to |
273 | file allows you to store all security sensitive data in a single place and to | 287 | obtain access and secret keys from the file named in the B<credentials> |
274 | tighten permissions accordingly. In the simplest case, this file contains a | 288 | setting (if it is defined). If unable to find credentials, B<glacier> attempts |
275 | single line with your access and secret keys separated by a semicolon, e.g.: | 289 | to get credentials from the instance store, assuming it is run on an EC2 |
290 | instance. It will exit if this attempt fails. | ||
291 | |||
292 | The credentials file allows you to store all security sensitive data in a | ||
293 | single place and to tighten permissions accordingly. In the simplest case, | ||
294 | this file contains a single line with your access and secret keys separated | ||
295 | by a semicolon, e.g.: | ||
276 | 296 | ||
277 | AEBRGYTEBRET:RTFERYABNERTYR4HDDHEYRTWW | 297 | AEBRGYTEBRET:RTFERYABNERTYR4HDDHEYRTWW |
278 | 298 | ||
279 | Additionally, the default region can be specified after a second semicolon: | 299 | Additionally, the default region can be specified after a second semicolon: |
280 | 300 | ||
281 | AEBRGYTEBRET:RTFERYABNERTYR4HDDHEYRTWW:us-west-1 | 301 | AEBRGYTEBRET:RTFERYABNERTYR4HDDHEYRTWW:us-west-1 |
282 | |||
283 | The default region is B<eu-west-1>. | ||
284 | |||
285 | =item Multiple accounts | ||
286 | 302 | ||
287 | If you have several accounts, you can list their credentials on separate lines. | 303 | If you have several accounts, you can list their credentials on separate lines. |
288 | In that case, B<glacier> will select the account with the access key supplied | 304 | In that case, B<glacier> will select the account with the access key supplied |
@@ -325,6 +341,21 @@ Sets the number of retries for failed transfers. Defaults to 10. | |||
325 | 341 | ||
326 | =back | 342 | =back |
327 | 343 | ||
344 | =item B<[transfer download]> | ||
345 | |||
346 | In addition to settings discussed above, the C<transfer download> section | ||
347 | can contain the following: | ||
348 | |||
349 | =over 8 | ||
350 | |||
351 | =item B<cachedir => I<DIR> | ||
352 | |||
353 | Names the directory used to keep files downloaded after successful | ||
354 | completion of archive retrieval jobs. This directory is managed by | ||
355 | B<glacier periodic> subcommand. The default value is F</var/lib/glacier/cache>. | ||
356 | |||
357 | =back | ||
358 | |||
328 | =item B<[database job]> | 359 | =item B<[database job]> |
329 | 360 | ||
330 | Configures the I<job database>. Job database is a local GDBM file, which | 361 | Configures the I<job database>. Job database is a local GDBM file, which |
diff --git a/lib/App/Glacier/Command/Periodic.pm b/lib/App/Glacier/Command/Periodic.pm index 18bd4f8..51c9718 100644 --- a/lib/App/Glacier/Command/Periodic.pm +++ b/lib/App/Glacier/Command/Periodic.pm | |||
@@ -18,9 +18,18 @@ B<glacier periodic> | |||
18 | 18 | ||
19 | =head1 DESCRIPTION | 19 | =head1 DESCRIPTION |
20 | 20 | ||
21 | Scans pending glacier jobs. For each job, checks its current status and if | 21 | Scans glacier jobs, cleaning up expired and failed ones and finishing |
22 | it the job is completed, retrieves the result. Typical usage is in the | 22 | up completed ones. For each completed archive retrieval job, the |
23 | crontab. | 23 | target file is downloaded and stored in directory configured by |
24 | the B<transfer.download.cachedir> configuration setting (default - | ||
25 | F</var/lib/glacier/cache>). This file will be removed when the | ||
26 | corresponding jobs expires. For each completed inventory retrieval job, | ||
27 | the vault inventory is obtained and stored in the database. | ||
28 | |||
29 | It is recommended to schedule this command for periodic execution in | ||
30 | your crontab, e.g.: | ||
31 | |||
32 | */4 * * * * root glacier periodic | ||
24 | 33 | ||
25 | =cut | 34 | =cut |
26 | 35 | ||
diff --git a/lib/App/Glacier/Directory.pm b/lib/App/Glacier/Directory.pm index 0ab998f..5e3ad46 100644 --- a/lib/App/Glacier/Directory.pm +++ b/lib/App/Glacier/Directory.pm | |||
@@ -12,7 +12,6 @@ use constant DB_INFO_KEY => ';00INFO'; | |||
12 | 12 | ||
13 | sub new { | 13 | sub new { |
14 | my ($class, $backend, $vault, $glacier, %opts) = @_; | 14 | my ($class, $backend, $vault, $glacier, %opts) = @_; |
15 | my $ttl = delete $opts{ttl}; | ||
16 | (my $vault_name = $vault) =~ | 15 | (my $vault_name = $vault) =~ |
17 | s/([^A-Za-z_0-9\.-])/sprintf("%%%02X", ord($1))/gex; | 16 | s/([^A-Za-z_0-9\.-])/sprintf("%%%02X", ord($1))/gex; |
18 | map { $opts{$_} =~ s/\$(?:vault|\{vault\})/$vault_name/g } keys %opts; | 17 | map { $opts{$_} =~ s/\$(?:vault|\{vault\})/$vault_name/g } keys %opts; |
@@ -23,7 +22,6 @@ sub new { | |||
23 | if ($self) { | 22 | if ($self) { |
24 | $self->{_vault} = $vault; | 23 | $self->{_vault} = $vault; |
25 | $self->{_glacier} = $glacier; | 24 | $self->{_glacier} = $glacier; |
26 | $self->{_ttl} = $ttl; | ||
27 | } | 25 | } |
28 | return $self; | 26 | return $self; |
29 | } | 27 | } |