-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a165401
commit 007e392
Showing
4 changed files
with
58 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,4 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/Thomascogez/dump-and-dumper/dumper" | ||
"github.com/docker/docker/api/types" | ||
"github.com/docker/docker/client" | ||
) | ||
|
||
func main() { | ||
cli, err := client.NewClientWithOpts(client.FromEnv) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
pgContainersToDump := dumper.FindContainersByTypes(containers, dumper.PG) | ||
|
||
dumper.DockerDumper{}.Dump(pgContainersToDump) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package upload | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/Thomascogez/dump-and-dumper/helpers" | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/credentials" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/s3/s3manager" | ||
) | ||
|
||
type S3Uploader struct { | ||
SecretKeyID string | ||
SecretKey string | ||
Endpoint string | ||
Region string | ||
Bucket string | ||
} | ||
|
||
func (s3Uploader S3Uploader) Upload(filePath string, fileName string) { | ||
s3ClientConfig := &aws.Config{ | ||
Endpoint: aws.String(s3Uploader.Endpoint), | ||
Region: aws.String(s3Uploader.Region), | ||
Credentials: credentials.NewStaticCredentials( | ||
s3Uploader.SecretKeyID, | ||
s3Uploader.SecretKey, | ||
"", | ||
), | ||
} | ||
|
||
sess, err := session.NewSession(s3ClientConfig) | ||
helpers.CheckError(err) | ||
|
||
uploader := s3manager.NewUploader(sess) | ||
dumpFile, _ := os.Open(filePath) | ||
defer dumpFile.Close() | ||
|
||
result, err := uploader.Upload(&s3manager.UploadInput{ | ||
Bucket: aws.String(s3Uploader.Bucket), | ||
Key: aws.String(fileName), | ||
Body: dumpFile, | ||
}) | ||
|
||
helpers.CheckError(err) | ||
|
||
fmt.Printf("[dump & dumper] - file uploaded to, %s\n", result.Location) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package upload | ||
|
||
type Uploader interface { | ||
Upload(filePath string, fileName string) | ||
} |