[英]Using Incron with Git for automatic backups
I'm trying to use Incron on Centos 7 to watch a directory for changes and back those changes up into a local git repo. 我正在尝试在Centos 7上使用Incron来监视目录中的更改,并将这些更改备份到本地git repo中。
As a test, I've created the following: 作为测试,我创建了以下内容:
/root/srv <-- The live source directory
/root/git <-- The backup location directory
/root/bin/git-autocommit <-- The script that does the backup and move
My git-autocommit script looks like this: #!/bin/bash 我的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"
And I've made it executable. 而且我已经使其可执行。
I'm now trying to execute: 我现在正在尝试执行:
incrontab -e /root/srv IN_MODIFY,IN_CREATE,IN_MOVED_FROM,IN_MOVED_TO /root/bin/git-autocommit
but I keep getting this error: 但我不断收到此错误:
invalid arguments - operation and source file cannot be combined
I can't exactly figure out what's going on. 我无法确切知道发生了什么。
it is probably too late for this answer, but adding a monitor is done in two steps 这个答案可能为时已晚,但是添加监视器需要两个步骤
incrontab -e
will open a file and in it you will add and save the command 将打开一个文件,并在其中添加和保存命令
/root/srv IN_MODIFY,IN_CREATE,IN_MOVED_FROM,IN_MOVED_TO /root/bin/git-autocommit
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.