Backup Specify 6 using Windows Scheduler (Part 1)
Friday, January 27th, 2012Sometimes it is nice to know your Scientific Collection is safe. And yes Specify asks you to back up your system but wouldn’t be great if you can have the machine do it automatically, say every Friday night. Well here are a few tips to get a batch in place that does just that. This guide is for Windows only.
Step 1 is to make a folder (example: c:\_specify_backup\) on your same computer. This has to be on the same computer that is running the mysql specify server. We are assuming this machine is running Windows.
Step 2 you will need to make a “specify_backup.bat” in that folder and edit it using notepad. I will use { } to fill in your own information here. C:\_specify_backup can be changed to any folder name you made in step 1. Now paste and modify the code as needed to match your connection information. Note that this is not your Specify connection but your mysql db connection information.
mysqldump {specify_database_you_want_to_backup} -u {db_user_with_permission} -p{user_pass} > C:\_specify_backup\specify6_{collectioncode}_%date:~-4%%date:~-7,2%%date:~-7,2%.sql
c:\_specify_backup\gzip.exe C:\_specify_backup\specify6_{collectioncode}_%date:~-4%%date:~-7,2%%date:~-7,2%.sql
Step 3 is to go to the GZip website (http://www.gzip.org/#exe) and download http://www.gzip.org/gzip124xN.zip and move the gzip.exe into the same specify backup folder. So now you should have the specify_backup.bat and gzip.exe files in your folder.
Step 4, lets test that it is working by going to Dos and running the .bat. To do this you can go to Start > Run and type “cmd” and a black dos window should open. You will need to type:
cd C:\_specify_backup\
specify_backup.bat
If all the connection information was correct you should see a specify_{collectioncode}_year_month_day.gz file. This is a compressed zip file containing your database.
Step 5 go ahead and delete this file using “My Computer” or any other way you normally would know how to delete a file. In dos it is “rm {filename}”.
Step 6 go to Start and search for “Scheduler” and you should see Task Scheduler. Click that and go to the next step.

Step 7 you need to click the “Task Schedule Library” then click “Create Task…”

Now fill in the information:
General > Name: Specify 6 Backup
General > Description: Creates weekly backup for Specify 6 databases.
Check “Run whether user is logged in or not”
Check “Run with highest privileges”
Triggers > New… >
Check: Weekly, Friday and change the time to 22:00 (to run at 10pm every Friday)
Actions > New… > Program Script: C:\_specify_backup\specify_backup.bat
Click ok and you should see a new task in your “Task Schedule”.
If you did everything correctly you should see a backup of you database right after 10pm every Friday. Since each file keeps the date in the name you will be able to keep all the weekly backups. If you see that your file is 0 in filesize then something probably did not work correctly with the connection.
In “Part 2” to of this blog we will address how to add another Scheduled Task to send these backups to an online FTP location for offsite storage. QuickTip: If you use Dropbox (https://www.dropbox.com/) you can change the mysqldump path to point to a dropbox folder and it will automatically get synchronized and backed up using the Dropbox service. Note: If you make that folder public then anyone will be able to download your Specify backups which may or may not be a good thing. Also note that you are storing a user/password to connect to mysql on your machine which may produce some risks. It might be advised to consult with your IT department to have a special user that restricts this connection only to your collection db only.
Any questions or comments feel free to send me an email at mikegiddens (at) silverbiology.com
Partner



