Hi guys,
I’m very new at Applescript, so please forgive me if my question is very obvious.
I’m making a simple backup script that logs in via SSH to my local linux server, tars a directory and secure copies the tar file back to my Mac.
This is what I’ve done so far:
tell application "Terminal"
activate
try
do script "ssh my.linuxserver.com -l username" in window 1
delay 15
do script "type_password" in window 1
on error
display dialog "Couldn't connect to server" buttons {"Oops!"} default button 1
end try
end tell
delay 2
tell application "Terminal"
do script "su" in window 1
delay 2
do script "type_password" in window 1
delay 2
do script "cd /usr/local" in window 1
delay 1
do script "tar -cf cvsroot_newbackup.tar ./cvsroot" in window 1
delay 15
do script "scp ./cvsroot_newbackup.tar username@my.mac.com:/Path/to/backupdir" in window 1
delay 10
do script "type_password" in window 1
delay 200
do script "rm -f ./cvsroot_newbackup.tar" in window 1
do script "exit" in window 1
do script "exit" in window 1
end tell
tell application "Terminal"
quit
end tell
At the end of this script I would like to rename the file ‘cvsroot_newbackup.tar’ to something like ‘cvsroot_20040705.tar’ where ‘20040705’ stands for the current date (yearmonthday). Naturally I would like AS to determine the current date by itself.
Can anybody please help me out with this?
Thanks in advance!