Island Roots Posted December 7, 2003 Share Posted December 7, 2003 I'm looking to create a cron job or some sort of script that automatically backs up my localhost files (including MySQL database). The localhost files are located at /Library/WebServer/Documents/ - I'd also like to back up my MySQL database. Preferrably it'd be in a compressed format. Is this feasible? A job for AppleScript? Anyone know where I can get started? Link to comment Share on other sites More sharing options...
ss1 Posted December 7, 2003 Share Posted December 7, 2003 cron job it sounds like. I've looked into trying to make one for my Debian box but haven't really tried to do one myself since I haven't found any reasonable documentation on how to do it.... ss1. Link to comment Share on other sites More sharing options...
isus Posted December 7, 2003 Share Posted December 7, 2003 applescript can do it, but it's probably much easier to either find a program that's already available or use a cron task. i would say find a program that can do automated backups. Link to comment Share on other sites More sharing options...
the evn show Posted December 7, 2003 Share Posted December 7, 2003 you don't say where you want to back them up to: I'm assuming another computer. The best method would be to use rsync and run it as a cron job. http://sunsite.dk/info/guides/rsync/rsync-mirroring.html to do it compressed you could use a shell script that is called via cron: #!/bin/bash cd ~/ mysqldump -u username -p password --all-databases > /Library/WebServer/Documents/mysqldump.sql tar --create --update --file=~/backup.tar.gz /library/webserver/documents rm /library/webserver/documents/mysqldump.sql I have a bad headache and I wrote that on the fly - there could be some stupid errors in there, but I'm sure you can get the general idea. dump that to a file called say "mybackupscript.sh" and chmod +x the thing so you can execute it. then just set that to run every day as a cron job by adding it to your crontab file 0 12 * * * /path/to/mybackupscript.sh Link to comment Share on other sites More sharing options...
Island Roots Posted December 7, 2003 Author Share Posted December 7, 2003 With the help of a friend, I've created the AppleScript below which grabs the MySQL data, tars it up within the localhost files, then tars the localhost files up and places them in ~/Documents/Backups/. do shell script "sudo tar -cvf /Library/WebServer/Documents/mysql-data.tar /usr/local/mysql/data" password "xxxxxx" with administrator privileges do shell script "sudo tar -cjvf ~/Documents/Backups/Localhost.tar.bz2 /Library/WebServer/Documents" password "xxxxxx" with administrator privileges I then set a crontab to run it at 7:30PM each night :) Link to comment Share on other sites More sharing options...
Kirkland Posted December 8, 2003 Share Posted December 8, 2003 You're welcome :hug: Link to comment Share on other sites More sharing options...
kairon Posted December 8, 2003 Share Posted December 8, 2003 Where is the crontab file? Link to comment Share on other sites More sharing options...
Kirkland Posted December 8, 2003 Share Posted December 8, 2003 It's not really a good idea to edit the crontab directly, just open up a new text file and enter what you want to be included in the crontab. Save it somewhere and in Terminal do crontab filename.txt And it'll include it into your crontab. FYI The crontab file is at /etc/crontab Link to comment Share on other sites More sharing options...
Recommended Posts