Rsync mit AppleScript, Ordner Synchronisieren bzw. Backup erstellen

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...
Code zum markieren einmal anklicken

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

This entry was posted in OS X, terminal and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CAPTCHA:


eight − 4 =

Subscribe without commenting

  • Seite übersetzen:


    Paypal for Pizza:




  • Kategorien


  • Letzte Kommentare

    • Niklas: Vielen Vielen Dank! So klappt es!
    • hubi: Servus Niklas, ich habe mir den Quellcode noch einmal angesehen und habe nun unter 10.7.3 einen Weg gefunden...
    • Niklas: Klingt super das Script. Leider bekomm ich immer folgende Fehlermeldung: error “„Mail“ hat einen Fehler...
    • Jürgen: Hallo Hubi, beim Abfragen von Kennworten gibt es noch eine böse Falle: Das Format, in dem security antwortet,...
    • hubi: Am einfachsten Du öffnest im AppleScript-Editor mal das Funktionsverzeichnis (unter Ablage) von iTunes. Ein...