【问题标题】:Using Incron with Git for automatic backups使用 Incron 和 Git 进行自动备份
【发布时间】:2016-12-09 01:23:40
【问题描述】:

我正在尝试在 Centos 7 上使用 Incron 来监视目录的更改并将这些更改备份到本地 git 存储库中。

作为测试,我创建了以下内容:

/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

我无法完全弄清楚发生了什么。

【问题讨论】:

    标签: git centos incron


    【解决方案1】:

    这个答案可能为时已晚,但添加监视器分两步完成

    incrontab -e 
    

    将打开一个文件并在其中添加并保存命令

    /root/srv IN_MODIFY,IN_CREATE,IN_MOVED_FROM,IN_MOVED_TO /root/bin/git-autocommit
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多