Specifically I would like to track my
grub.conf
(/boot/grub/grub.conf
) and some oracle files (i.e./db/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
).I attempted using links; however etckeeper/git only tracks where the link points to, not the actual contents. And I can not create hard links as the files are on another volume.
I know I could setup another GIT repository but I would rather have it all within etckeeper.
Update
Based on nealmcb’s answer I came up with the following script:
#!/bin/sh set -e # Based on nealmcb's idea/script 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, 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_dir "/boot/grub" mirror_dir "/root"
To add or remove a path you simply add or remove the
mirror_dir
call at the bottom.
Answer
I edited the above script to also include plain files.
maybe someone should add a possibility to configure this outside a script (in the etckeeper config?) and send this as a patch to joey hess?
#!/bin/sh
set -e
# Based on nealmcb's + ErebusBat's script 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, 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 --del $LOCAL_PATH/ $MIRROR_ROOT/$LOCAL_PATH
}
mirror_file() {
LOCAL_PATH=$1
DIRPATH=`dirname $LOCAL_PATH | head -n 1`
echo " $LOCAL_PATH"
mkdir -p $MIRROR_ROOT/$DIRPATH
rsync -a --del $LOCAL_PATH $MIRROR_ROOT/$DIRPATH
}
mirror_file "/var/srv/foo_bar/blog/config.py"
mirror_file "/var/srv/foo_bar_another_host/trac/conf/trac.ini"
mirror_file "/tmp/wildcards/*.jpg"
Attribution
Source : Link , Question Author : ErebusBat , Answer Author : Community