syncPhotos.sh 769 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. # User config
  3. export BASE_LOCAL="/Volumes/iPhoto"
  4. SOURCE_LOCAL="/mnt/media/Pictures/iPhoto.sparsebundle"
  5. SOURCE_REMOTE="https://webdav.opendrive.com"
  6. TARGET="Shared.photolibrary"
  7. # App config
  8. SYNC_BIN="${HOME}/bin/video/backup/sync.sh"
  9. # Ensure the remote drive is available
  10. "${VIDEO_DIR}/backup/checkMount.sh"
  11. # Mount the local drive if needed
  12. MOUNTED_LOCAL=0
  13. if [ ! -d "${BASE_LOCAL}" ]; then
  14. MOUNTED_LOCAL=1
  15. hdiutil attach -readonly "${SOURCE_LOCAL}" >/dev/null 2>&1
  16. fi
  17. # Backup if all went well
  18. if [ -d "${BASE_LOCAL}" ]; then
  19. "${SYNC_BIN}" "${TARGET}" 1000
  20. fi
  21. # Detach the local drive if we mounted it
  22. if [ -d "${BASE_LOCAL}" ] && [ $MOUNTED_LOCAL -gt 0 ]; then
  23. hdiutil detach "${BASE_LOCAL}" >/dev/null 2>&1
  24. fi
  25. # Always exit cleanly
  26. exit 0