Skip to content

Instantly share code, notes, and snippets.

@niftycode
Created November 24, 2021 06:57
Show Gist options
  • Save niftycode/490c25ef449de6ee2ae88f52dde35a01 to your computer and use it in GitHub Desktop.
Save niftycode/490c25ef449de6ee2ae88f52dde35a01 to your computer and use it in GitHub Desktop.
Backup data on macOS using Apple Script and rsync
-- Backup data using rsync
-- Version 1.0
-- Create a List Menu
set usbList to {"1b", "1c"}
set usbList to choose from list usbList with prompt "Bitte ein Sicherungsziel auswählen:" default items {"1b"}
-- If the user cancels the process, a dialog is displayed
if usbList is false then
beep
display alert "Der Vorgang wurde abgebrochen!"
else
-- Confirm the process
set theDialogText to "Es wurde das Gerät " & (usbList) & " ausgewählt. Soll das Backup gestartet werden?"
display dialog theDialogText with icon caution
-- Start the backup
try
do shell script "rsync -av --delete /Users/bodo/Desktop/Artikel/ /Volumes/" & usbList & "/Artikel"
-- Display notification
display notification "Es wurden alle Dateien gesichert." with title "Backup-Skript" subtitle "Sicherungsprozess beendet!" sound name "Frog"
on error errMsg
display dialog "ERROR: " & errMsg buttons {"OK"} with icon stop
end try
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment