I'm a software engineer with a bit of source code on my machine mostly versioned in git. I'd like to back them up from time to time, since I have made stupid mistakes which resulted in loss of code. For example, I rebased the wrong branch being tired, and screwed up my local branch, losing code. Fortunally, I made a copy of it the previous day, and could quickly recover.
When doing it manually, the process is something like this:
- Create a Backup Directory ~/Backups/YYYY/MM/DD
- Find all .git directories. They are usually in subdirectories under ~/Developer, such as ~/Developer/wernerstrydom/website/.git
- For each .git archive the parent directory, excluding certain directories (.terraform, .terraform.d, dist).
- Copy the archive to the Backup directory, using the relative path to ~/Developer. This is because some folder names may be identical, such as ~/Developer/wernerstrydom/website and ~/Developer/bloudraak/website. These are actually distinct repositories in different GitHub organizations.
I really only want to run it on git repositories that have changed since the last time the process was run.
Would this be possible with Hazel?
Thanks,
Werner