开发者

launchd remote rdiff-backup

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>
            <int开发者_如何学Ceger>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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜