Q: AppleScript to automate Time Machine backup on NAS
Hey Team,
I'm trying to create a AppleScript that will
1.) Mount a network share via smb. Lets say the location is smb:\\TITAN\BACKUPS\MANUAL
2.) Prompt the user for input (Lets say the prompt says "Enter the Job Name"), and saves the input as a variable (lets say the variable name is JobName, and has been set to 1234).
3.)Create a folder in smb:\\TITAN\BACKUPS\MANUAL with the variable's value inputted from the user. (smb:\\TITAN\BACKUPS\MANUAL\1234 now would exist)
4.)Create a sparsebundle image at the location we created in step 3. The size will be 1024 gigabytes, the volume name will be the same as what the user set as the job name (1234 in our case), and the sparsebundle will be named the job name as well (1234.sparsebundle).
5.)I will need to then mount the sparsebundle.
6.)I then need to tell time machine to use the said sparsebundle volume to be our backup disk.
7.)I then need to have time machine's properties to open up, so that I can select which files to exclude.
Could someone provide some input? Using the user defined variable to navigate with and name the sparse bundle has me stumped after trying to google solutions.
The last 4 lines of the script are where my main hang up is.
________________________________________________________________________________ ______________________
try
mount volume "smb://TITAN/BACKUPS/MANUAL"
end try
set JobName to text returned of (display dialog "Enter Job Name:" default answer "Job_Name")
tell application "Finder"
make new folder at "smb://TITAN/BACKUPS/MANUAL" with properties{name:JobName}
end tell
cd /Volumes/TITAN/BACKUPS/MANUAL
cd(JobName)
hdiutil create -size 1024g -type SPARSEBUNDLE -fs "HFS+J" -volname "JobName" JobName.sparsebundle
mount volume "/Volume/folkvangr/backups/manual/JobName
sudo tmutil setdestination /volumes/JobName
_______________________________________
MacBook Pro, OS X Yosemite (10.10.5)
Posted on Dec 6, 2015 9:00 PM