forked from gwatts/dyndump
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmd_metadata.go
46 lines (40 loc) · 1.11 KB
/
cmd_metadata.go
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
// Copyright 2016 Gareth Watts
// Licensed under an MIT license
// See the LICENSE file for details
package main
import (
"html/template"
"os"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/gwatts/dyndump/dyndump"
)
var metadataTmpl = template.Must(template.New("md").Parse(`
Table Name...........: {{ .TableName }}
Table ARN............: {{ .TableARN }}
Status ..............: {{ .Status }}
Backup Type .........: {{ .Type }}
Backup Start Time ...: {{ .StartTime }}
Backup End Time .....: {{ .EndTime }}
Compressed (bytes) ..: {{ .CompressedBytes }}
Uncompressed (bytes) : {{ .UncompressedBytes }}
Item Count ..........: {{ .ItemCount }}
Part Count ..........: {{ .PartCount }}
`))
type metadataDumper struct {
// options
s3BucketName *string
s3Prefix *string
}
func (md *metadataDumper) run() {
sr := &dyndump.S3Reader{
S3: s3.New(session.New()),
Bucket: *md.s3BucketName,
PathPrefix: *md.s3Prefix,
}
metadata, err := sr.Metadata()
if err != nil {
fail("Failed to read metadata from S3: %v", err)
}
metadataTmpl.Execute(os.Stdout, metadata)
}