etckeeper 可以用于跟踪 /etc 之外的配置文件吗?

Ere*_*Bat 11 git etckeeper

具体来说,我想跟踪我的grub.conf( /boot/grub/grub.conf) 和一些 oracle 文件(即/db/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora)。

我尝试使用链接;但是 etckeeper/git 只跟踪链接指向的位置,而不是实际内容。而且我无法创建硬链接,因为文件在另一个卷上。

我知道我可以设置另一个 GIT 存储库,但我宁愿将其全部放在 etckeeper 中。

更新

根据 nealmcb 的回答,我想出了以下脚本:

#!/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"  
Run Code Online (Sandbox Code Playgroud)

要添加或删除路径,您只需添加或删除mirror_dir底部的调用。

小智 6

我编辑了上面的脚本以包含普通文件。

也许有人应该添加一个在脚本之外配置它的可能性(在 etckeeper 配置中?)并将其作为补丁发送给 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"
Run Code Online (Sandbox Code Playgroud)