답변:
~ / bin / timemachine :
#!/bin/bash
d="Time Machine" # (change this to match the name of your backup drive)
diskutil mount "$d" && tmutil startbackup -b && diskutil eject "$d"
~ / 라이브러리 /LaunchAgents/timemachine_eject.plist :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
<plist version="1.0">
<dict>
<key>Label</key>
<string>timemachine_eject</string>
<key>Program</key>
<string>/Users/username/bin/timemachine</string> <!-- Replace "username" with your username. "~/bin/timemachine" doesn't work -->
<key>StartInterval</key>
<integer>120</integer> <!-- run every two minutes for testing. -->
<!-- Change this to a higher number like 43200 (run every 12 hours) once you've confirmed it works. -->
</dict>
</plist>
스크립트를 실행 가능하게 만들고 기본 plist를 언로드 한 후 새 plist를로드하십시오.
chmod +x ~/bin/timemachine
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.backupd-auto.plist
launchctl load ~/Library/LaunchAgents/timemachine_eject.plist
plist 파일을 변경하려면 언제든지 언로드하고로드해야합니다.
launchctl unload ~/Library/LaunchAgents/timemachine_eject.plist
launchctl load ~/Library/LaunchAgents/timemachine_eject.plist
더 좋은 방법이있을 수 있지만 한 가지 해결책은 Applescript입니다. 백업 후 사과 스크립트를 실행하는 방법을 아직 찾지 못했지만 다음과 같이 할 수 있습니다.
do shell script "/System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper >/dev/null 2>&1 &"
eject disk somedrivename
이를 정기적으로 수행하려면 cron 작업에 첨부 할 수 있습니다.