Take control over configuration files and store them in version control system using etckeeper utility created by Joey Hess, which seamlessly integrates with package management tools inside Debian operating system.
Use the following command to install etckeeper utility.
$ sudo apt-get install etckeeper
Configuration is stored inside
/etcdirectory are stored using
/etc is initialized and committed after etckeeper installation,
use the the following command to repeat first step.
$ sudo etckeeper init
Repository will be only initialized, nothing will be committed. In any case the existing repository will be not overwritten.
Delete etckeeper repository inside
$ sudo etckeeper uninit ** Warning: This will DESTROY all recorded history for /etc, ** including the git repository. Are you sure you want to do this? [yN] y Proceeding..
Commit all changes inside
$ sudo etckeeper commit "modified motd file" [master 24bca01] modified motd file Author: milosz <[email protected]> 1 file changed, 1 insertion(+)
List modified, created or deleted files.
$ sudo etckeeper vcs status # On branch master # Changes not staged for commit: # (use "git add
..." to update what will be committed) # (use "git checkout -- ..." to discard changes in working directory) # # modified: motd # no changes added to commit (use "git add" and/or "git commit -a")
Reset all modifications.
$ sudo etckeeper vcs reset --hard HEAD is now at 24bca01 modified motd file
List log entries
Show commit logs.
$ sudo etckeeper vcs log commit 24bca015d8bad77eaa85bef6988ab2d94928562e Author: milosz
Date: Sat Nov 1 23:11:12 2014 +0000 modified motd file commit 0ea331237044537e8ebc95020352f60fef068546 Author: milosz Date: Sat Nov 1 23:10:46 2014 +0000 Initial commit
Recover older version of specified file
Checkout file from specified revision.
$ sudo etckeeper vcs checkout 0ea331 motd
Show applied but not committed changes.
$ sudo etckeeper vcs diff diff --git a/motd b/motd index 2d3a0a3..6c21842 100644 --- a/motd +++ b/motd @@ -3,6 +3,3 @@ The programs included with the Debian GNU/Linux system are free the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. -Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent -permitted by applicable law. -
Check if there are uncommitted changes
The following command will return true if there are uncommitted changes.
$ sudo etckeeper unclean $ if [ "$?" -eq "0" ]; then echo "uncommitted changes"; else echo "no uncommitted changes"; fi uncommitted changes
/etcdirectory, as you can always use
-dparameter to specify different directory.
Uncommited changes are committed daily (see
/etc/cron.daily/etckeeper file), use
AVOID_DAILY_AUTOCOMMITS configuration directive to alter this behavior.