具体来说,我想跟踪我的grub.conf ( /boot/grub/grub.conf )和一些oracle文件(即/db/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora )。
我试图使用链接; 然而etckeeper / git只跟踪链接指向的位置,而不是实际的内容。 而且我不能创build硬链接作为文件在另一个卷上。
我知道我可以设置另一个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"
要添加或删除path,只需在底部添加或删除mirror_dir调用即可。
我编辑了上面的脚本也包括纯文件。
也许有人应该添加一个可能性来configuration这个外部脚本(在etckeeperconfiguration?),并将其作为补丁发送给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"
etckeeper允许你将它与其他系统集成。
我也想跟踪/ boot中update-grub所做的更改,所以我把下面的代码放在/etc/etckeeper/commit.d/20mirror-outside-files
这种方式任何时候etckeeper被称为其他原因(当我安装软件,有时夜间等),它会抓住和跟踪在最新的GRUBconfiguration的修订。
我发明了这个惯例,把这个东西放在/ etc / mirror / path-to-outside-file /etc/Mirror/boot/grub/grub.cfg ,例如/etc/Mirror/boot/grub/grub.cfg但是如果有人有另一个这样的惯例的先例,我很乐意听说它。
#!/bin/sh set -e # 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. echo etckeeper: mirroring outside files mkdir -p /etc/Mirror/boot/grub cp -p /boot/grub/grub.cfg /etc/Mirror/boot/grub
更新:
请注意,由于某些原因,当你执行apt-get remove或purge时,etckeeper不会运行这个操作,例如删除一个旧的内核。 奇怪….但是你可以在这种情况下手动运行sudo etckeeper commit ,或者在手动update-grub 。
etckeeper现在有一个-d选项来指示它必须在哪个目录下运行。
虽然挂钩触发etckeeper通常使用构造作为etckeeper pre-install ,…,您将不得不添加使用etckeeper pre-install -d /boot/grub钩子。 这样可以避免文件重复。
请注意,如果您认为systemd目标,服务,…文件是configuration文件(毕竟, /lib/systemd下的文件与/etc/init.d下的文件没有区别),那么这个-d选项将帮助您跟踪/lib/systemd发生的情况。
我不认为etckeeper会这样做,但有几个解决scheme:
反向链接:将文件系统上的链接放在/ etc /
脚本将这些文件复制到/ etc(备份)和/ etc(还原)。 然后使用这些脚本定期或在适当的git钩子。
从简介: etckeeper init -d /directory
但要小心! 下一次运行它,或下一周,如果您忘记了-d path ,它可以创build一个新的独立本地回购,默认位置在/etc 。
所以我build议在etckeeper.conf中提交这个重要的细节。 一个快速的, grep /etc \``which etckeeper\`` ,显示: ETCKEEPER_DIR=/etc ,所以只需在etckeeper.conf中使用这个variables即可。
sed -i '1 i\ETCKEEPER_DIR=/' /etc/etckeeper/etckeeper.conf
从“保留”其他的东西,包括文件属性的愿望, etckeeper init -d /为我工作,但后来忘记细节是烦人的。 所以最好保存这个细节。 另外, uninit不会撤消使用VCS,它只是删除整个本地回购。