I have some sites at a webhotell where my only way of backing up the database is through phpmyadmin. I´m working on a script that will read the source of a page that spits out the database as sql if the password in the url is correct and the ip is my servers, and saving it as a backup-file once a day.
This is my first applescript, and I never seem to get it done.
I would like to loop an array of urls, create a file for each url with the date as it´s name in a specific folder. Then I can activate the script using iCal.
I know that this is easy stuff, but I need some help to get started, I know that I need curl, but that´s about it right now.
/Pontus
I´m looking at using curl -O http://www.server.com/file.asp and then moove and rename the file to something like /domain/20051220-0001.sql
instead of
set code to (do shell script “curl http://www.server.com/file.asp”) and then saving this to a file of the right name.
The thing is that I don´t know how to do either.
do shell script “curl -O http://www.site.com/backup/index.asp”
do shell script “mv index.asp backup/site/date.sql”
Now I´ve come this far. Now I need the date for naming the file and then I´m done!
try this:
do shell script "date \"+%Y%m%d\""
See man: date in the terminal for the rules of formatting a date.
Sweet!
The final result:
set sNow to (do shell script "date \"+%Y%m%d-%H%M\"")
do shell script "curl -O [url=http://www.site.com/backup/index.asp]http://www.site.com/backup/index.asp"[/url]
do shell script "mv index.asp backup/site.com/" & sNow & ".txt"