私はこれをやろうとしています:
外部 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