git-confident - Automate Configuration Backup to a Remote Git repository

  • Keep a backup of single files scattered around your file system,

  • Add those files to a Git repository

  • When they change, they get backed up

  • Restore your files


  • A remote (preferably non-public) server to push your repository to.

Multiple Branches for Computers with Similar Configurations

If you are backing up similar configurations from different computers, you may want to keep several versions in branches. If that is the case, just create the branch locally and check it out.

Getting Started

Create a Git Repository of The Files You Want Backed Up

  • Create an empty Git repository:

$ mkdir ~/my_backup
$ git init
  • Add some files, mimicking their full path:

$ mkdir -p etc
$ cp /etc/hosts etc/
$ git add etc/hosts
  • Set up a git repository on your remote server:

$ mkdir -p ~/gitpath/my_backup
$ cd ~/gitpath/my_backup
$ git init --bare
  • Add your remote server as 'origin':

$ git remote add origin ssh://
  • Check commit and push work:

$ git commit -m "I'm starting by backing up my /etc/hosts"
$ git push

Set Up a Cron Job

$ crontab -e
   13    23     *     *     *     cd ~/my_backup && git-confident

Advanced Use

Ignore files and folders

You can store extra files in your backup repository (like text notes) adding them to a .gcignore file:

$ echo SETUP_NOTES >> .gcignore
$ git add .gcignore

so git-confident won't restore them. Similarly to .gitignore behaviour, you can ignore an entire folder by adding a .gcignore file inside it.

Folder scan

git-confident keeps a copy of each file added to git. This is not very useful when you have an entire folder to backup. You can track a whole folder using a .gcrecusrive file (acts like .gitignore):

$ touch etc/apache2/.gcrecusive
$ git add etc/apache2/.gcrecusive