I am trying to use git as a configuration management/backup solution for multiple directories. My thinking was to setup a cron job to do nightly commits and push to our central repository. What is the best way to achieve this for folders that aren't contiguous? The only thing I was thinking of was initializing the git repository in /
and then add the folders as necessary. Is there a better way? Here are the example folders I would like to backup.
/etc/folder1/
/opt/folder2/
/var/log/folder1/
I think honestly one repo in / is the best bet for what I'm looking to do.
In that case (and provided your .gitignore
is "on point", to avoid adding everything), you can, for each folder, do a:
git -C /path/to/folder1 add .
git commit -m "Add /path/to/folder1"
git push
And repeat for folder2
, folder3
, and so on... (assuming those folders are not nested).