How to automate regular Parse backups with Capybara

I have a love-hate relationship with Parse. We use it for some of the API backend on our mobile app Sweeble and there are both upsides (convenience, decent uptime, solid built-in analytics) and downsides (crappy documentation, non-existent customer service, abundant bugs, lack of auto-scaling).

One thing that has really bugged me is that generating a backup (JSON dump of your data) can only be done through the web UI. 3 years ago Parse said creating alternative options was "on their roadmap", but 3 years later it's yet to exist.

Parse backs up the data on their end, which is great if an error occurs by them through database errors or whatever else. Unfortunately this isn't helpful if a Parse user inadvertently deletes or clears something on their end. Which, as we all know, mistakes happen.

A hacky solution to automate backups is by using Capybara, which will spin up a browser that can be interacted with through code. Below I've added a Ruby script that will navigate the Parse UI to trigger a email to download the JSON dump.

The script uses Selenium as the driver. It can be switched to use a webkit browser like PhantomJS for speed and to move it more into the background.

To use the script, update the class parameters at the bottom of the script to use your Parse login info and app name. Feel free to move these into environment variables to keep them better hidden.

Next, setup the script to run with a daily cronjob or any other frequency you want.

Lastly, this script triggers an email to the email address associated with your account to download the dump. If you want to get more fancy, this could be fully automated with an email webhook, but I've found it easy enough to download directly from the emails when they arrive. The links in the emails expire after 7 days.