~/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"
~/Library/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>
Haz el script ejecutable, descarga el plist por defecto y carga el nuevo:
chmod +x ~/bin/timemachine
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.backupd-auto.plist
launchctl load ~/Library/LaunchAgents/timemachine_eject.plist
Cada vez que quieras hacer cambios en el archivo plist, tienes que descargarlo y cargarlo:
launchctl unload ~/Library/LaunchAgents/timemachine_eject.plist
launchctl load ~/Library/LaunchAgents/timemachine_eject.plist
4 votos
Una observación interesante: al hacer una copia de seguridad de TimeMachine en una unidad de red, TimeMachine montará automáticamente, hará la copia de seguridad y luego desmontará el recurso compartido remoto de TimeMachine en la unidad de red. Me pregunto si se podría aprovechar esto para conseguir lo que se quiere.