Skip Navigation LinksHome > View Post

Using the scheduler to backup your Mobile Service database

Recently I launched my first iOS application called ‘doto’. doto is a todolist app with two areas of focus: simplicity and sharing. I wanted a super simple application to share lists with my wife (groceries, trip ideas, gift ideas for the kids, checklist for the camping trip etc). For more info, check out the mini-site or watch the 90 second video:

image

Now that I have a real app that stores real people’s data, I feel a responsibility to ensure that I take good care of it. Whilst it’s unlikely; it is possible that I could do something silly like drop a SQL table and lose a lot of data that is important to those users. So taking a periodic backup and keeping that in a safe location is advisable.

SQL Azure has a cool export feature that creates a ‘.bacpac’ file that contains your schema and your data – it saves the file to blob storage. And what’s more, they have a service endpoint with a REST API.

This means it’s easy for me to invoke an export from a Mobile Services script, even better, I can use the scheduler to do a daily backup.

Here’s the script I use; notice how the URL of the export service varies depending on the location of your database and server.

And now I just have to set a schedule, I’m going to go for 1 minute past midnight UTC.

image

Restore

If I ever need to restore the backup data I can create a new database from an import, right in the portal:

image

Which opens a cool wizard that even helps me navigate my blob storage containers to find the appropriate .bacpac file. To hook this new database up to my Mobile Service I could do an ETL over to the existing connected database or use the Change DB feature in the Mobile Service CONFIGURE tab:

image

Tags:

 
Josh Post By Josh Twist
5:23 PM
20 Jan 2013

» Next Post: Dispatching to different query functions in Mobile Services
« Previous Post: A quick lick of paint

Comments are closed for this post.

Posted by Spike @ 20 Jan 2013 6:09 PM
The video on the demo site is REEEEEALLY slow to load...
Would you upload it to youtube or as a smaller format?

Posted by Josh @ 20 Jan 2013 7:09 PM
Now available on youtube: http://www.youtube.com/watch?v=sg3iGGA0u6I

© 2005 - 2014 Josh Twist - All Rights Reserved.