Hello People.
Need some help here, been using duplicate file/folder for a while, but i need to backup over network,
using a wireless macbook, what i need is a script to test for internet connection every 5 min using ping.
if there is no active connection, i want to stop a running backup script, and start it again when connection
comes back, im using do shell script and rdiff-backup so far and need to continue to do so…
this is what i got now, but the init_backup script is not working as wanted, when i run it from script editor
it seem to work but not right :/…
i start with starting the backup program on boot. and then start the check for connection, and it closes the
test1 application when no connection was found, 5 min later it started up the test1 program again but got
timeout, and this is here im stuck. pretty sure the problem are in init_backup script
Backup Files
-- This is saved as an application and started on boot using hide option
-- Want this to backup every 3 hours
repeat with shotcount from 1 to 100
do shell script ("/opt/local/bin/rdiff-backup ~/Library/Mail/ user@hostname::/home/user/rdiff-restore/Library/Mail/`date +%d_%m_%y`")
delay (60 * minutes) -- delaytime
end repeat
init_backup script
-- Check network connectin and start/stop application
repeat with shotcount from 1 to 100
-- Server IP
set DNS_LookUp to "10.0.0.102"
-- Shell script to ping backup server
set DNS_CMD to "ping -q -c 1 " & DNS_LookUp & " | grep \"packet loss\" | awk '{ print $7 }'"
-- Tell script to send ping request
set DNS_Report to do shell script DNS_CMD
-- If ping request return null or to high loss, close application
if DNS_Report = "" or DNS_Report = "100%" then
-- Find and close application
set Process_Id to do shell script "ps ax | grep test1 | grep -v grep | awk '{ print $1 }'"
-- If ID was found, kill application.
if Process_Id is not "" then
do shell script ("kill -9 " & Process_Id)
end if
else
-- Check if application is found in process list
tell application "System Events" to get name of every process
set ProcessList to result
-- Start backup application
if ProcessList does not contain "test1" then
tell application "test1" to activate
end if
end if
-- Delay ping request
delay (5 * minutes)
end repeat
Thanks.
– mkh