[the name of this file should have an "sh" extension!!] #!/bin/bash #Backup script for learn web sites. Does not include user information #Change directories if cd /Library/WebServer/Documents then echo "...changing directories" else echo "...couldn't change directories" exit 0 fi # dump the old backup file if rm websitename.tar.gz then echo "... removing zip file" else echo "... couldn't find zip file to remove" fi # dump the old sql dump file if rm website.sql.gz then echo "... removing sql zip file" else echo "... couldn't find sql zip file to remove" fi #Tar the web directories if tar -cf website.tar website then echo "...website tar file created" else echo "...couldn't tar the website folder" exit 0 fi # zip the tar file if gzip website.tar then echo "... tar file zipped" else echo "...couldn't zip the tar file" exit 0 fi if mysqldump -u superuser -ppasswordhere --opt --all-databases > /Library/WebServer/Documents/website.sql then echo "dumping MySQL databases" else echo "couldn't dump the databases" exit 0 fi if gzip website.sql then echo "sql file zipped" else echo "couldn't zip the sql file" exit 0 fi if scp /Library/WebServer/Documents/website.sql.gz user:password@10.10.10.10:/Users/user/Sites/backupfolder/website.sql.gz.test echo "backup transfer of website.sql.gz successful!" else echo "couldn't ftp the sql archive to the other computer. sorry." exit 0 fi if scp /Library/WebServer/Documents/website.tar.gz user:password@10.10.10.10:/Users/user/Sites/backupfolder/website.tar.gz.test echo "backup ftp transfer sucessful!" else echo "couldn't secure copy the tar achive to the other computer. sorry." exit 0 fi #End echo "...Done" exit 1