[英]Using Incron with Git for automatic backups
我正在尝试在Centos 7上使用Incron来监视目录中的更改,并将这些更改备份到本地git repo中。
作为测试,我创建了以下内容:
/root/srv <-- The live source directory
/root/git <-- The backup location directory
/root/bin/git-autocommit <-- The script that does the backup and move
我的git-autocommit脚本看起来像这样:#!/ bin / bash
REP_DIR="/root/git" # repository directory
NOTIFY_DIR="/root/srv" # directory to version
cd $REP_DIR
GIT_WORK_TREE=$NOTIFY_DIR /usr/bin/git add .
GIT_WORK_TREE=$NOTIFY_DIR /usr/bin/git commit -a -m "auto"
而且我已经使其可执行。
我现在正在尝试执行:
incrontab -e /root/srv IN_MODIFY,IN_CREATE,IN_MOVED_FROM,IN_MOVED_TO /root/bin/git-autocommit
但我不断收到此错误:
invalid arguments - operation and source file cannot be combined
我无法确切知道发生了什么。
这个答案可能为时已晚,但是添加监视器需要两个步骤
incrontab -e
将打开一个文件,并在其中添加和保存命令
/root/srv IN_MODIFY,IN_CREATE,IN_MOVED_FROM,IN_MOVED_TO /root/bin/git-autocommit
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.