Shaun Hevey
Backup & Restore Shortcuts
May 17, 2020

iOS Shortcuts is a fantastic tool that allows you to automate a lot of tasks on your iOS device and with the introduction of parameters in iOS 13 it allowed developers to extend Shortcuts by exposing new action that you can use in your shortcuts. At the same time Apple also removed the option to import a shortcut from a file, in the past you could of used this import your shortcut backups.

Thanks to fantastic developers that are extending Shortcuts we now have other options to help backup and restore those shortcuts. In this post I want to share with you how I can backup to and restore from Working Copy.

Apps Required

Let's take a look at the apps that I am using to achieve this.

Before I get in to the actual shortcuts I use to achieve this let me explain what each of these apps do and why I am using them.

Working Copy

Working copy is fully fledged Git client for iOS, it allows you to interact with Git repositories in a variety of ways including through the files app, x-callback-urls, in the app itself and what I am using in the Shortcuts. If you don't know what Git is then you can read about it here. You can also find more information about Working Copy from its website or from the Apple App Store

Just to note you don't have to use working copy you could manipulate these shortcuts to just store these files in the the files app etc but that is out of scope for this post.

Data Jar

Data Jar is a fairly new application, its sole purpose is to store and retrieve data for use in your shortcuts. I am using this application to store configuration of which Git repository I am storing my Shortcuts in. You can find more information about Data Jar from its website or from the Apple App Store

GizmoPack

GizmoPack is an application that exposes a number of new actions to Shortcuts. It currently adds 18 new actions to Shortcuts, and as it has only been on the App Store for a week at the time of writing of this post I suspect it wont be that way for long. Just to note that the actions I am using in these shortcuts will require you to purchase the GizmoPack Pro (available via a once off in-app purchase). You can read about GizmoPack here or get it from the Apple App Store

Shortcuts

Now that you have all the applications required here are the two shortcuts I have created to Backup and Restore.

Save Shortcuts in Working Copy

Restore Shortcuts from Working Copy

Save Shortcuts in Working Copy

This shortcut is used to store your shortcuts in your Git repository in Working Copy. At a high level this shortcut goes through a number of steps to make sure you have selected the repository to store your shortcuts in.

Select Save Shortcuts Shortcut

Then it gets a list of all your shortcuts and asks you which ones you would like to store in your Git repository, by default it will store all your shortcuts.

Select Shortcuts to save

Once you have selected your shortcuts then it uses the newly added action in GizmoPack "Encode Property List" it will either allow you to Decode property lists to JSON or Encode JSON to a property list. Property lists are how shortcuts are stored in iOS. All you have to do is pass the Shortcut object to it and it will return you JSON representation of it. This JSON file is what I then store in Working Copy.

Example of a Shortcut file in Working Copy

The shortcut then asks if you would like to commit all the files to your Git repository.

Commits shortcuts menu

Restore Shortcuts from Working Copy

Now you have saved your shortcuts lets look at how you can save them back in to Shortcuts from Working Copy.

This shortcut goes through the similar process to the save shortcut to make sure the configuration in Data Jar for the repository to get shortcuts from is valid.

Select Restore Shortcuts Shortcut

Once the repository is validated the shortcut will show you a list of backed up shortcuts. When you have chosen the shortcut to restore it uses the Encode Property List action from GizmoPack and converts the JSON back in to a property list.

Select Shortcuts to restore from Working Copy

The shortcut will then present an alert for you to create an iCloud link. The reason it needs to generate an iCloud link is at the time of writing they are the only way to import shortcuts.

Create iCloud link

If all goes well you will be presented with the import shortcut screen. Choose the name you would like to import the shortcut as. Just to note if you leave it as the default you will get .shortcut at the end of the name.

Set name of shortcut

To import click Add Untrusted Shortcut at the bottom of the import screen.

Click Add untrusted shortcut

Once your shortcut has been imported you can find in the list with all your other shortcuts. Text Format Shortcut