Guest User

Untitled

a guest
Apr 21st, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #!/bin/bash
  2. # This script backs up stuff from my iMac to a SMB share on my PC.
  3.  
  4. # == Configuration Variables ==
  5. # backupServer - the host name (or IP) of my PC, and the name of
  6. # the SMB share I set up
  7. # backupImagePath - local folder that the SMB share will be mounted
  8. # to. This is created and removed automatically.
  9. # backupImageFile - absolute path to the disk image my backup lives
  10. # in (must use Disk Utility to create it first). In this case, I
  11. # used the previous variable to generate the full path.
  12. # backupVolName - This is the name of the disk image's mounted disk.
  13. # sourcePath - Path to the root of what you want to back up (in this
  14. # case, my home directory).
  15.  
  16.  
  17. # Config
  18. backupServer=//hostname/shareName
  19. backupImagePath=/Volumes/WinPC
  20. backupImageFile=$backupImagePath/iMac.sparseimage;
  21. backupVolName=BackupImage;
  22. sourcePath=~/*;
  23.  
  24.  
  25. # Create sharepoint dir
  26. echo " --> Creating folder for sharepoint...";
  27. mkdir $backupImagePath
  28.  
  29.  
  30. # Mount windows SMB share to above dir
  31. echo " --> Mounting sharepoint...";
  32. if [ -e $backupImagePath ]; then
  33. mount_smbfs $backupServer $backupImagePath
  34. else
  35. echo " ==> ERROR: Unable to prepare mount-point.";
  36. fi
  37.  
  38.  
  39. # Attach Disk Image
  40. if [ -e $backupImageFile ]; then
  41. echo " --> Mounting disk image...";
  42. hdiutil attach $backupImageFile;
  43. else
  44. echo " ==> ERROR: Unable to find disk image.";
  45. fi
  46.  
  47.  
  48. # Backup files to disk image
  49. echo " --> Backing up the files...";
  50. rsync -avPE --delete $sourcePath /Volumes/$backupVolName;
  51.  
  52.  
  53. # Cleanup
  54. echo " --> Unmounting disk image and sharepoint...";
  55. hdiutil detach /Volumes/$backupVolName;
  56. umount $backupImagePath;
  57. rmdir $backupImagePath;
  58.  
  59. echo "";
  60. echo "";
  61.  
  62. echo "Script finished.";
Add Comment
Please, Sign In to add comment