3

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/

dobbs
  • 1,089
  • 6
  • 22
  • 45
  • 2
    maybe this answer helps: https://stackoverflow.com/questions/2383754/git-how-do-you-add-an-external-directory-to-the-repository – Timothy Truckle Jul 09 '18 at 16:20
  • What's wrong with one git repo per root folder? – jingx Jul 09 '18 at 17:41
  • too many repositories for our group. it will get messy in git that way. I read through the post that @TimothyTruckle posted and while it definitely solves the problem, I think honestly one repo in `/` is the best bet for what I'm looking to do. – dobbs Jul 09 '18 at 18:54

1 Answers1

2

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).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250