Archive for January, 2012

Backup Specify 6 using Windows Scheduler (Part 1)

Friday, January 27th, 2012

Sometimes 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

Static Maps for CartoDB

Monday, January 23rd, 2012

CartoDB (http://www.cartodb.com) has and will be a big game changer for 2012.  One thing it is great at  making are tiled, interactive maps for the web.  One of the important things with the projects we work on here at SilverBiology is being able to produce a single image of those tiles to be used with non interactive and offline projects.  And so we decided to write our own PHP static map program.


Git Hub Project: https://github.com/silverbiology/cartodb-staticmap-php

World map tiles are broken down into individual 256 pixel images called tiles.  The closer you get to the surface of the earth the more tiles (higher level of detail) exists.  Most online mapping engines, including CartoDB work in this manner.  What we have done is to take those generated tiles and reassemble them so that the end result is one single image of only what you want to see.

Our CartoDB static map program focuses on two techniques.  The first is what we call viewport mode.  In this mode we take two lat/lng points to form a geospatial box.  In this mode you can make use of any of the CartoDB features as you would when using their interface.  Two examples are shown below.  The first is only the tile cells joined together where the two points are found.  In this case you will find extra white space but should overlap with matching Google tiles.  The second example is having the image trimmed to the exact lat/lng pixels on those tile images.

One with trimming.

The second method that is most common is to select a single lat/lng point and center an image based on a zoom resolution and a width and height.  An example looks something like this.

The idea behind creating this project was to allow us to easily combine and generate a static image in real time or to write a script that would make use of this class to cache a set of images. CartoDB Static Maps works both as a image URL, as a included PHP class in your project, or directly from the command line interface on your server.  Some practical uses cases would be to:

  • Generate Static Distribution Maps
  • “Save as” feature from an interactive map
  • Generate images for downloading images of maps
  • Offline support

We hope others can make use of our work with this static map project and encourage you to help participate in making it better.  If you would like to contribute on this project please contact mikegiddens (at) silverbiology.com