This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
6 changed files
with
105 additions
and
25 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
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
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 +1,41 @@ | ||
package pipes | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"github.com/bitfield/script" | ||
"gov.gsa.fac.backups/internal/logging" | ||
"gov.gsa.fac.backups/internal/vcap" | ||
) | ||
|
||
// export AWS_PRIVATE_ACCESS_KEY_ID=longtest | ||
// export AWS_PRIVATE_SECRET_ACCESS_KEY=longtest | ||
// export AWS_S3_PRIVATE_ENDPOINT="http://minio:9000" | ||
// mc alias set myminio "${AWS_S3_PRIVATE_ENDPOINT}" minioadmin minioadmin | ||
// # Do nothing if the bucket already exists. | ||
// # https: //min.io/docs/minio/linux/reference/minio-mc/mc-mb.html | ||
// mc mb --ignore-existing myminio/gsa-fac-private-s3 | ||
|
||
// https://bitfieldconsulting.com/golang/scripting | ||
func S3(in_pipe *script.Pipe, up *vcap.CredentialsS3, prefix string, source_db string) *script.Pipe { | ||
os.Setenv("ACCESS_KEY_ID", up.AccessKeyId) | ||
os.Setenv("SECRET_ACCESS_KEY", up.SecretAccessKey) | ||
|
||
cmd := []string{ | ||
"s3", | ||
"cp", | ||
fmt.Sprintf("s3://%s/backups/%s-%s.dump", | ||
up.Bucket, | ||
prefix, | ||
source_db), | ||
} | ||
|
||
// Combine the slice for printing and execution. | ||
combined := strings.Join(cmd[:], " ") | ||
// This will log the password... | ||
logging.Logger.Printf("BACKUPS Running `%s`\n", combined) | ||
logging.Logger.Printf("BACKUPS s3 targeting %s", prefix) | ||
return in_pipe.Exec(combined) | ||
} |
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