Rsync mit AppleScript, Ordner Synchronisieren bzw. Backup erstellen
Man zieht einmal den zu sichernden Ordner als
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
Letzte Kommentare