Die Idee ist eigentlich voll simpel uns sicher schon irgendwie mal programmiert worden. Das nette an dieser Lösung ist, dass die Ziel und Quell-Ordner über Aliase gekennzeichnet werden.Man zieht einmal den zu sichernden Ordner als
Alias in den Skript-Ordner, dann den ZielOrdner und bennent diese entsprechen in um (SOURCE und DESTINATION). Beim nächsten Start, synchronisiert das Skript mit rsync und schreibt alles in ein Log, das 2000 Zeilen nie übersteigt...
Rsync mit AppleScript, Ordner Synchronisieren bzw. Backup erstellen
try
set sourcepath to ""
set destipath to ""
set h to path to me
tell application "Finder"
set h to container of h
if (count of every alias file of h) = 2 then
set thealiases to every alias file of h
repeat with thealias in thealiases
if name of thealias = "SOURCE" then
set sourcepath to characters 1 through -2 of (POSIX path of (original item of thealias as alias)) as text
else if name of thealias = "DESTINATION" then
set destipath to POSIX path of (original item of thealias as alias)
end if
end repeat
if destipath ≠ "" and sourcepath ≠ "" then
do shell script "rsync -avE --delete-after " & quoted form of sourcepath & " " & quoted form of destipath & " >> " & quoted form of POSIX path of (h as alias) & "rsync_log.txt || echo -n"
do shell script "tail -n 2000 " & quoted form of POSIX path of (h as alias) & "rsync_log.txt | cat> " & quoted form of POSIX path of (h as alias) & "rsync_log.txt2; mv " & quoted form of POSIX path of (h as alias) & "rsync_log.txt2 " & quoted form of POSIX path of (h as alias) & "rsync_log.txt"
else
error "irgendwas ist da falsch gelaufen"
end if
end if
end tell
on error msg
error "irgendwas ist da falsch gelaufen" & msg
end try