Difference between revisions of "Etckeeper"
Jump to navigation
Jump to search
(Adds commentary about hard-linked files) |
(use explicit paths in example) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Intro == | == Intro == | ||
− | + | Etckeeper is a great tool created by Joey Hess to use your favorite VCS to keep track of what's going on in <code>/etc</code>. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Extending etckeeper == | == Extending etckeeper == | ||
Say you want to keep track of changes to the configuration directory or file of some app. You also want to make it automatic and painless. Etckeeper leverages the commit hook in git to create that mirror. So, for example, the most critical aspect of your [[wiki]] is the <code>LocalSettings.php</code> configuration file. You don't want to commit the file to the version control of the project because it would expose sensitive data. etckeeper can be used to track changes to any file on the filesystem, but it's done discretely on the host. | Say you want to keep track of changes to the configuration directory or file of some app. You also want to make it automatic and painless. Etckeeper leverages the commit hook in git to create that mirror. So, for example, the most critical aspect of your [[wiki]] is the <code>LocalSettings.php</code> configuration file. You don't want to commit the file to the version control of the project because it would expose sensitive data. etckeeper can be used to track changes to any file on the filesystem, but it's done discretely on the host. | ||
− | |||
Line 48: | Line 30: | ||
echo " $LOCAL_PATH" | echo " $LOCAL_PATH" | ||
mkdir -p $MIRROR_ROOT/$LOCAL_PATH | mkdir -p $MIRROR_ROOT/$LOCAL_PATH | ||
− | rsync -a | + | rsync -a $LOCAL_PATH/ $MIRROR_ROOT/$LOCAL_PATH |
} | } | ||
Line 58: | Line 40: | ||
rsync -a $LOCAL_PATH $MIRROR_ROOT/$DIRPATH | rsync -a $LOCAL_PATH $MIRROR_ROOT/$DIRPATH | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
########################################### | ########################################### | ||
Line 69: | Line 47: | ||
mirror_file "/var/www/html/wiki/LocalSettings.php" | mirror_file "/var/www/html/wiki/LocalSettings.php" | ||
mirror_dir "/home/greg/data" | mirror_dir "/home/greg/data" | ||
− | + | mirror_dir "/home/greg/bin" | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</source> | </source> | ||
Line 109: | Line 53: | ||
[[Category:Version Control]] | [[Category:Version Control]] | ||
[[Category:DevOps]] | [[Category:DevOps]] | ||
+ | |||
[[Category:VCS]] | [[Category:VCS]] | ||
+ | [[Category:Version Control]] |
Revision as of 11:38, 22 July 2016
Intro[edit | edit source]
Etckeeper is a great tool created by Joey Hess to use your favorite VCS to keep track of what's going on in /etc
.
Extending etckeeper[edit | edit source]
Say you want to keep track of changes to the configuration directory or file of some app. You also want to make it automatic and painless. Etckeeper leverages the commit hook in git to create that mirror. So, for example, the most critical aspect of your wiki is the LocalSettings.php
configuration file. You don't want to commit the file to the version control of the project because it would expose sensitive data. etckeeper can be used to track changes to any file on the filesystem, but it's done discretely on the host.
vi /etc/etckeeper/commit.d/20mirror-outside-files
#!/bin/sh
set -e
# Greg Rundlett info@equality-tech.com
# based on code from http://serverfault.com/questions/211425
# If you want other configuration data or files on the system also
# opportunistically tracked via etckeeper, use this script to copy them in.
# If there is a hook of some sort available related to the files
# you're mirroring, (e.g. Apache restart)
# you can call etckeeper directly and track them
# proactively, rather than just opportunistically here.
MIRROR_ROOT=/etc/etckeeper.mirror.d
echo "etckeeper: mirroring outside files to $MIRROR_ROOT/:"
mirror_dir() {
LOCAL_PATH=$1
echo " $LOCAL_PATH"
mkdir -p $MIRROR_ROOT/$LOCAL_PATH
rsync -a $LOCAL_PATH/ $MIRROR_ROOT/$LOCAL_PATH
}
mirror_file() {
LOCAL_PATH=$1
DIRPATH=`dirname $LOCAL_PATH`
echo " $LOCAL_PATH"
mkdir -p $MIRROR_ROOT/$DIRPATH
rsync -a $LOCAL_PATH $MIRROR_ROOT/$DIRPATH
}
###########################################
## ADD lines below to invoke the system ###
###########################################
mirror_file "/var/www/html/wiki/LocalSettings.php"
mirror_dir "/home/greg/data"
mirror_dir "/home/greg/bin"