0

我正在尝试这样做:

当外部 USB HD 上的“BCKUNIVERSITA”分区挂载时,LAUNCHD 通过 backup.com 启动“backup.com”,挂载“BCKUNIVERSITA”内的加密 DMG(“riassunti.sparsebundle”)。然后将目录“/DATI/UNIVERSITA”中的 rsync 文件复制到已安装的 dmg“riassunti.sparsebundle”中。

这是关于 LaunchD plist 的代码:

`<?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>com.rsync.backup</string>
    <key>LowPriorityIO</key>
    <true/>
    <key>Program</key>
        <string>/Users/ikar0/Library/Scripts/backup.com</string>
    <key>ProgramArguments</key>
    <array>
        <string>backup.com</string>
    </array>
    <key>WatchPaths</key>
    <array> 
        <string>/Volumes</string> 
    </array>
</dict>
</plist>`

这是“backup.com”中的代码:

#!/bin/bash
    folderToBackup="/Volumes/DATI/UNIVERSITA" 
    backupVolume="/Volumes/BCKUNIVERSITA" 
    backupTo="/Volumes/RIASSUNTI/" 
    # mounts encrypted image 
    echo -n 465tyu567 | hdiutil attach -stdinpass /Volumes/BCKUNIVERSITA/riassunti.sparsebundle 
    sleep 10
    if [ ! -e ${backupVolume} ] 
    then echo -n "[*]-- BackupVolume NOT connected - Exiting" | logger exit 0 
    else echo -n "[*]-- BackupVolume Connected - Continuing" | logger 
    fi
    # Copy the files over. Here we are using rsync. 
    for i in ${folderToBackup} 
    do 
    echo -n "[*]-- Starting Rsync of ${i} to ${backupTo}" | logger 
    rsync -aq $folderToBackup $backupTo
    echo -n "[*]-- rsync of ${i} to ${backupTo} complete..."| logger 
    done 
    # once the rsync is done, unmount the drive. 
    hdiutil detach $backupTo 
    exit 0

Here are the errors from console :



16/06/12 01.13.51   com.rsync.backup[14139] rsync: recv_generator: mkdir "/Volumes/RIASSUNTI/UNIVERSITA" failed: Permission denied (13)
16/06/12 01.13.51   com.rsync.backup[14139] *** Skipping everything below this failed directory ***
16/06/12 01.13.51   com.rsync.backup[14139] rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-40/rsync/main.c(992) [sender=2.6.9]
16/06/12 01.13.51   com.rsync.backup[14139] hdiutil: detach failed - Nessun documento o directory esistente
16/06/12 01.13.56   com.rsync.backup[14271] /dev/disk3              GUID_partition_scheme           
16/06/12 01.13.56   com.rsync.backup[14271] /dev/disk3s1            EFI                             
16/06/12 01.13.56   com.rsync.backup[14271] /dev/disk3s2            Apple_HFS                       /Volumes/RIASSUNTI 1
16/06/12 01.14.06   com.rsync.backup[14271] rsync: recv_generator: mkdir "/Volumes/RIASSUNTI/UNIVERSITA" failed: Permission denied (13)
16/06/12 01.14.06   com.rsync.backup[14271] *** Skipping everything below this failed directory ***
16/06/12 01.14.06   com.rsync.backup[14271] rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-40/rsync/main.c(992) [sender=2.6.9]
16/06/12 01.14.06   com.rsync.backup[14271] hdiutil: detach failed - Nessun documento o directory esistente
4

1 回答 1

0

错误消息是说运行 rsync 的用户没有权限做

mkdir "/Volumes/RIASSUNTI/UNIVERSITA"

您可能需要设置您的 sudoers 文件,以便您可以更改:

rsync -aq $folderToBackup $backupTo

sudo rsync -aq $folderToBackup $backupTo
于 2013-01-10T16:57:36.070 回答