Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # This script backs up stuff from my iMac to a SMB share on my PC.
- # == Configuration Variables ==
- # backupServer - the host name (or IP) of my PC, and the name of
- # the SMB share I set up
- # backupImagePath - local folder that the SMB share will be mounted
- # to. This is created and removed automatically.
- # backupImageFile - absolute path to the disk image my backup lives
- # in (must use Disk Utility to create it first). In this case, I
- # used the previous variable to generate the full path.
- # backupVolName - This is the name of the disk image's mounted disk.
- # sourcePath - Path to the root of what you want to back up (in this
- # case, my home directory).
- # Config
- backupServer=//hostname/shareName
- backupImagePath=/Volumes/WinPC
- backupImageFile=$backupImagePath/iMac.sparseimage;
- backupVolName=BackupImage;
- sourcePath=~/*;
- # Create sharepoint dir
- echo " --> Creating folder for sharepoint...";
- mkdir $backupImagePath
- # Mount windows SMB share to above dir
- echo " --> Mounting sharepoint...";
- if [ -e $backupImagePath ]; then
- mount_smbfs $backupServer $backupImagePath
- else
- echo " ==> ERROR: Unable to prepare mount-point.";
- fi
- # Attach Disk Image
- if [ -e $backupImageFile ]; then
- echo " --> Mounting disk image...";
- hdiutil attach $backupImageFile;
- else
- echo " ==> ERROR: Unable to find disk image.";
- fi
- # Backup files to disk image
- echo " --> Backing up the files...";
- rsync -avPE --delete $sourcePath /Volumes/$backupVolName;
- # Cleanup
- echo " --> Unmounting disk image and sharepoint...";
- hdiutil detach /Volumes/$backupVolName;
- umount $backupImagePath;
- rmdir $backupImagePath;
- echo "";
- echo "";
- echo "Script finished.";
Add Comment
Please, Sign In to add comment