启动远程 rdiff 备份

发布于 2024-12-01 11:37:42 字数 2460 浏览 3 评论 0原文

我的 backupscript 遇到问题,它似乎不适用于 OS X launchd

这是我想要运行的脚本:

#
# backupscript
#
NOW=$(date +"%y%m%d-%H:%M:%S") 
LOGFILE=/usr/local/server/log/$NOW
SOURCE=/
DESTINATION=remote@remote::/media/backup
INCLUDE_LIST=/usr/local/server/include-list
KEEP_TIME=40B

RDIFF_BACKUP=/usr/local/bin/rdiff-backup

$RDIFF_BACKUP --print-statistics -v5 --include-globbing-filelist $INCLUDE_LIST $SOURCE $DESTINATION > $LOGFILE
$RDIFF_BACKUP --remove-older-than $KEEP_TIME $DESTINATION

如您所见,它没什么特别的,并且在不使用 launchd 时可以工作。

但是,当我使用 launchd 运行它时,它并没有... XML 文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>backup.plist</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/sh</string>
        <string>/usr/local/server/backup.sh</string>
    </array>
    <key>LowPriorityIO</key>
    <true/>
    <key>AbandonProcessGroup</key>
    <true/>
    <key>Nice</key>
    <integer>1</integer>
    <key>StartCalendarInterval</key>
    <array>
        <dict>
            <key>Hour</key>
            <integer>10</integer>
            <key>Minute</key>
            <integer>0</integer>
        </dict>
        <dict>
            <key>Hour</key>
            <integer>14</integer>
            <key>Minute</key>
            <integer>0</integer>
        </dict>
        <dict>
            <key>Hour</key>
            <integer>18</integer>
            <key>Minute</key>
            <integer>0</integer>
        </dict>
        <dict>
            <key>Hour</key>
            <integer>22</integer>
            <key>Minute</key>
            <integer>54</integer>
        </dict>
    </array>
</dict>
</plist>

脚本正在运行,但没有对远程主机进行备份。 backup.plist 位于 /Library/LaunchDeamons 中,因此应以 root 身份运行。

我不知道可能是什么问题,权限也应该没问题。这已经困扰我好几天了......

有什么建议吗?

I am having a problem with my backupscript that does not seem to work with OS X launchd.

This is my script that I would like to run:

#
# backupscript
#
NOW=$(date +"%y%m%d-%H:%M:%S") 
LOGFILE=/usr/local/server/log/$NOW
SOURCE=/
DESTINATION=remote@remote::/media/backup
INCLUDE_LIST=/usr/local/server/include-list
KEEP_TIME=40B

RDIFF_BACKUP=/usr/local/bin/rdiff-backup

$RDIFF_BACKUP --print-statistics -v5 --include-globbing-filelist $INCLUDE_LIST $SOURCE $DESTINATION > $LOGFILE
$RDIFF_BACKUP --remove-older-than $KEEP_TIME $DESTINATION

As you see, it is nothing special and it works when not using launchd.

However, when I run it with launchd it does not... The XML-file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>backup.plist</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/sh</string>
        <string>/usr/local/server/backup.sh</string>
    </array>
    <key>LowPriorityIO</key>
    <true/>
    <key>AbandonProcessGroup</key>
    <true/>
    <key>Nice</key>
    <integer>1</integer>
    <key>StartCalendarInterval</key>
    <array>
        <dict>
            <key>Hour</key>
            <integer>10</integer>
            <key>Minute</key>
            <integer>0</integer>
        </dict>
        <dict>
            <key>Hour</key>
            <integer>14</integer>
            <key>Minute</key>
            <integer>0</integer>
        </dict>
        <dict>
            <key>Hour</key>
            <integer>18</integer>
            <key>Minute</key>
            <integer>0</integer>
        </dict>
        <dict>
            <key>Hour</key>
            <integer>22</integer>
            <key>Minute</key>
            <integer>54</integer>
        </dict>
    </array>
</dict>
</plist>

The script is running but there is no backup made to the remote host. backup.plist is located in /Library/LaunchDeamons, so it should be run as root.

I have no idea what could be the problem, the permissions should also be ok. This has been bothering me for some days now...

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诗笺 2024-12-08 11:37:42

我没有发现任何明显错误,所以我要做的第一件事就是使日志记录更加完整,看看是否表明了问题——包括 stderr 和 stdout,以及整个脚本,而不仅仅是主脚本rdiff-备份命令。在脚本的开头执行类似的操作:

NOW=$(date +"%y%m%d-%H:%M:%S") 
exec &>/usr/local/server/log/$NOW

然后删除 >; $LOGFILE 部分稍后以防止其被覆盖。如果您需要更多详细信息,请尽早添加 set -x,这样它就会在执行之前打印每个命令。

I don't spot anything obviously wrong, so the first thing I'd do is make the logging more complete, and see if that indicates the problem -- include stderr as well as stdout, and for the entire script, not just the main rdiff-backup command. Do something like this at the beginning of the script:

NOW=$(date +"%y%m%d-%H:%M:%S") 
exec &>/usr/local/server/log/$NOW

and then remove the > $LOGFILE part later to keep it from overwriting. If you need even more detail, add set -x early on, so it'll print each command before it's executed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文