Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. echo =====================================
  4. echo `date` Backing up Documents
  5.  
  6. # The URL to your remote AFP server. You can test your URL using command-K in the Finder.
  7. AFP_URL=afp://user:password@afp.server.com/Share
  8.  
  9. # The place where the AFP server is mounted. By default this will be in /Volumes someplace.
  10. AFP_DIRECTORY=/Volumes/Share
  11.  
  12. # A path relative to `AFP_DIRECTORY` where the encrypted disk image can be found. Create this yourself
  13. # with Disk Utility as an encrypted sparsebundle Disk Image. Be sure to make the maximum size large enough.
  14. IMAGE_PATH=backups/Backups.sparsebundle
  15.  
  16. # The password you used when you create the disk image.
  17. IMAGE_PASSWORD=disk_image_password
  18.  
  19. # Where the encrypted disk image is mounted when you open it in the Finder. Usually this will be somewhere in /Volumes.
  20. IMAGE_MOUNT_POINT=/Volumes/Backups
  21.  
  22. # The directory you'd like to back up.
  23. BACKUP_DIRECTORY=/Users/koehn/Documents
  24.  
  25. # Mount the remote AFP volume. We need to create the local directory where the mount will occur.
  26. mkdir -p "$AFP_DIRECTORY"
  27. mount_afp "$AFP_URL" "$AFP_DIRECTORY"
  28.  
  29. # Mount the backup image. In this mode the user must enter the password on the command line.
  30. # Here we DON'T need to create the directory where the mount will occur. Go figure.
  31. echo -n "$IMAGE_PASSWORD" | hdiutil attach -stdinpass "$AFP_DIRECTORY/$IMAGE_PATH"
  32.  
  33. # Backup the software to the remote encrypted volume using Apple's rsync 2.6.9 from 2006.
  34. # rsync -avE --exclude .DS_Store "$BACKUP_DIRECTORY" "$IMAGE_MOUNT_POINT"
  35.  
  36. # Use this if you manually installed the (better) rsync 3.1.0 or later (limits bandwidth to 500KB/s)
  37. /usr/local/bin/rsync -aviAEX --bwlimit=500 --delete --exclude .DS_Store "$BACKUP_DIRECTORY" "$IMAGE_MOUNT_POINT"
  38.  
  39. # Unmount the encrypted disk image.
  40. hdiutil detach "$IMAGE_MOUNT_POINT"
  41.  
  42. # Unmount the remote directory (will delete the directory we crated with `mkdir` above).
  43. diskutil unmount "$AFP_DIRECTORY"
  44.  
  45. echo `date` Done backing up Documents
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement