mirror of
https://github.com/cooperspencer/gickup.git
synced 2025-05-11 01:35:35 +02:00
add backup creation date directory in s3 (#320)
* add backup creation date directory in s3 * fix var name --------- Co-authored-by: y.bazhenov <y.bazhenov@arenadata.io>
This commit is contained in:
parent
533b98ba0c
commit
97c26eef7b
4 changed files with 21 additions and 10 deletions
|
@ -281,6 +281,7 @@ destination:
|
||||||
zip: false # if true, will zip the entire git repo into a single zip file and upload that instead
|
zip: false # if true, will zip the entire git repo into a single zip file and upload that instead
|
||||||
usessl: true # wheter to use ssl or not
|
usessl: true # wheter to use ssl or not
|
||||||
storageclass: "" # storage class for all repos to be uploaded to this S3 bucket. E.g. for AWS: STANDARD, STANDARD_IA, GLACIER, etc.
|
storageclass: "" # storage class for all repos to be uploaded to this S3 bucket. E.g. for AWS: STANDARD, STANDARD_IA, GLACIER, etc.
|
||||||
|
datecreatedir: false # if true, gickup will create a directory for backup with the creation date
|
||||||
cron: 0 22 * * * # optional - when cron is not provided, the program runs once and exits.
|
cron: 0 22 * * * # optional - when cron is not provided, the program runs once and exits.
|
||||||
# Otherwise, it runs according to the cron schedule.
|
# Otherwise, it runs according to the cron schedule.
|
||||||
# See timezone commentary in docker-compose.yml for making sure this container runs
|
# See timezone commentary in docker-compose.yml for making sure this container runs
|
||||||
|
|
|
@ -554,6 +554,10 @@
|
||||||
"storageclass": {
|
"storageclass": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Storage class applied to all repos uploaded to this S3 bucket (optional)"
|
"description": "Storage class applied to all repos uploaded to this S3 bucket (optional)"
|
||||||
|
},
|
||||||
|
"datecreatedir": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "If true, gickup will create a directory for backup with the creation date"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
|
5
main.go
5
main.go
|
@ -155,6 +155,7 @@ func substituteHomeForTildeInPath(path string) string {
|
||||||
|
|
||||||
func backup(repos []types.Repo, conf *types.Conf) {
|
func backup(repos []types.Repo, conf *types.Conf) {
|
||||||
checkedpath := false
|
checkedpath := false
|
||||||
|
currentDateDir := time.Now().Format("2006-01-02") + "/"
|
||||||
|
|
||||||
for _, r := range repos {
|
for _, r := range repos {
|
||||||
log.Info().
|
log.Info().
|
||||||
|
@ -217,6 +218,10 @@ func backup(repos []types.Repo, conf *types.Conf) {
|
||||||
r.Name = path.Join(r.Hoster, r.Owner, r.Name)
|
r.Name = path.Join(r.Hoster, r.Owner, r.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d.DateCreateDir {
|
||||||
|
r.Name = currentDateDir + r.Name
|
||||||
|
}
|
||||||
|
|
||||||
defer os.RemoveAll(tempdir)
|
defer os.RemoveAll(tempdir)
|
||||||
tempClonePath := path.Join(tempdir, r.Name)
|
tempClonePath := path.Join(tempdir, r.Name)
|
||||||
_, err = local.TempCloneBare(r, tempClonePath)
|
_, err = local.TempCloneBare(r, tempClonePath)
|
||||||
|
|
|
@ -555,6 +555,7 @@ type S3Repo struct {
|
||||||
Structured bool `yaml:"structured"`
|
Structured bool `yaml:"structured"`
|
||||||
Zip bool `yaml:"zip"`
|
Zip bool `yaml:"zip"`
|
||||||
StorageClass string `yaml:"storageclass"`
|
StorageClass string `yaml:"storageclass"`
|
||||||
|
DateCreateDir bool `yaml:"datecreatedir"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s3 S3Repo) GetKey(accessString string) (string, error) {
|
func (s3 S3Repo) GetKey(accessString string) (string, error) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue