簡體   English   中英

結合使用Incron和Git進行自動備份

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM