cooperspencer / gickup

https://cooperspencer.github.io/gickup-documentation/
Apache License 2.0
962 stars 34 forks source link

Ability to have local path be time based #129

Closed jclusso closed 1 year ago

jclusso commented 1 year ago

I'm confused how this is really considered a backup without this functionality. If any repository is compromised and receives a bad commit of some sort, the backup will reflect that rendering it useless. It would be nice if path was evaluated so you could include the date in it some how.

cooperspencer commented 1 year ago

What exactly do you mean by that? Like cloning the repository and adding the clone date and time to the path? /clone-path/repo-$DATE

cooperspencer commented 1 year ago

Or creating a zip file with the date after the cloning is done

jclusso commented 1 year ago

Both would be great! If path was evaluated one could do anything they want regarding date and time control.

Having a compressed or zip option would be awesome for storage savings too if you could have it compress each repo. Having each one separate would be ideal vs one big zip.

We were just going to dump everything in a folder that's mounted to AWS S3 but right now we'd have to do some post processing in a separate script or something and can't use your built in cron .

jclusso commented 1 year ago

Ex: /backup/2023/01/06/github.com/username/repo.zip

cooperspencer commented 1 year ago

I really like this idea. I'll look into it

cooperspencer commented 1 year ago

I just added the function to add the date to the backup path. I used the same structure as in your example. it's in the time_to_path_and_zip branch, if you want to try it out.

jclusso commented 1 year ago

Awesome! Building from source now!

jclusso commented 1 year ago

@cooperspencer I think that does the trick. I'm debating if we should add the time, but I'm not sure if that's overkill on this. I just tried it out and I can't decide.

Having daily backups probably suffices for my usecase, but I don't know about others. I think that if time was included it would be best to have date like you have and time as another option. If you don't think it's necessary I completely understand! This change is huge as it is. I would've made a PR myself, but I don't really know any Go and wasn't sure where to start looking here.

Looking forward to the zip functionality!

cooperspencer commented 1 year ago

just pushed the zip functionality. regarding date, I am thinking about adding date to the zip-file and maybe also add a keep parameter to delete old backups.

jclusso commented 1 year ago

@cooperspencer I'm indifferent as long as the functionality is there. How would the keep parameter work? I was just going to rely on an S3 policy to delete old files that were older than a certain date, but if you did something that was like keep the last X number backups that would simplify things!

cooperspencer commented 1 year ago

That's what I planned. It would be like keep X backups

jclusso commented 1 year ago

That sounds great! Zip works nicely too.

cooperspencer commented 1 year ago

Awesome! I'll add the keep parameter tomorrow. I'll keep you posted

cooperspencer commented 1 year ago

@jclusso Just implemented the keep parameter. It just keeps X backups

cooperspencer commented 1 year ago

I might remove the date parameter again. I think it is sufficient to have the keep option because it adds the unix timestamp to the backup path.

jclusso commented 1 year ago

What about something like this with keep enabled and no date option.

/backup-path/github.com/[repo-name]/[timestamp].git

cooperspencer commented 1 year ago

This sounds good

cooperspencer commented 1 year ago

@jclusso just removed the date parameter and implemented that keep creates a directory/zip file with the timestamp as name. /backup-path/github.com/[owner]/[repo-name]/[timestamp]

jclusso commented 1 year ago

@cooperspencer nice! Appears to work as expected!

cooperspencer commented 1 year ago

released with v0.10.10