I do something similar. On my server I run this script each hour which dumps my sugar database, zips it and sends it to MobileMe for back up. In the previous script which I run as root via Cronix, I download it to my local Mac, start XAMPP and it reloads the local copy of sugarCRM. In this way I have four copies of the file... the production version, a zipped version on the server, a zipped version on MobileMe, and a local version. I only use the local version in case I lose my internet connection. If that happens and I have to make changes to local version, I use phpMyAdmin to manually dump the local version re-load the production version. Happens maybe once a year.
I can't tell you how long it took me to figure out how to use cadaver. PITA. You have to have the password and user stuff in a separate file which you don't see in this script... cadaver knows the name and reads it. Why Apple had to use webdav and not the FTP protocol is beyond me!
- Code: Select all
#!/bin/sh
#create a date-time suffix for new fle.
b=$(date +"%m%d%y%H%M%S")
#dump sugar to backup and zip it.
/usr/local/bin/mysqldump -eqf --add-drop-table -h localhost -u xxxxxxx --password=xxxx sugar2 | gzip > dbsugar_$b.bak.gz
#save it to a folder on server after deleting whatever is in it.
rm /usr/home/xxx/backupsugar/backup_current_sugar/*.bak.gz
cp /usr/home/xxx/backupsugar/dbsugar_$b.bak.gz /usr/home/xxx/backupsugar/backup_current_sugar/
#send a copy of zip file to MobileMe using cadaver
#get name of file from folder. (not sure why this is done... has something to do in passing name of file to the lame cadaver program. FTP is better!)
filename=$(ls /usr/home/xxx/backupsugar/backup_current_sugar/*)
#code for sending this to Apple server (there is a hidden file with password and user name that is necessary. See man page for cadaver)
/usr/local/bin/cadaver -t idisk.mac.com/xxx/yyyzzzr << EOF > /dev/null
delete *
put $filename
quit
EOF
I hope this helps anyone who wants to keep multiple copies of a database. I run my insurance agency (link below) on SugarCRM so I can't be too careful about backing up. (I also burn a cd of the zip file once a day... just in case Apple's MobileMe, my dedicated server at my ISP (PairNetworks), and my local Mac Mini machine all get wiped out at the same time!)
Al
http://www.insol123.com