Applescript to Unmount Volumes Matching a Pattern
This is how I'd do it... The following example AppleScript code will unmount any mounted disk that starts with "Backup":

set listOfDisks to list disks
set listOfDisksToUnmount to {}

repeat with thisDisk in listOfDisks
    if thisDisk starts with "Backup" then
        copy contents of thisDisk to end of listOfDisksToUnmount
    end if
end repeat

if listOfDisksToUnmount is not {} then
    repeat with thisDisk in listOfDisksToUnmount
        do shell script "diskutil unmount /Volumes/" &amp; thisDisk's quoted form
    end repeat
end if


Note: If you have an issue with the unmount verb with diskutil, try unmountDisk instead.

Note: contents in copy contents of thisDisk to end of listOfDisksToUnmount doesn't copy the contents of the disk, it copies the contents of the list item, which is the name of the disk.



Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.