Windows and macOS make it easy to back up your files, and to restore a working copy of any file that becomes damaged, thanks to their respective File History and Time Machine features.
Things aren’t so straightforward on iPadOS. Its iCloud Backup feature can restore your whole iPad to an earlier state, which is useful if you have to reset or replace the device, but it doesn’t allow for recovery of individual files.
However, you can build and automate a back-up routine for your Affinity documents using Apple’s free Shortcuts app.
What our shortcut does
In this article, we’ll show you how to build a shortcut that, at a scheduled time each day, will create a Zip archive of Affinity documents modified on the same day and upload it to the cloud.
More precisely, we mean modified and saved. For the back-up routine to be effective, you’ll need to get into the habit of returning to your Affinity app’s home screen and saving all modified documents to ensure they are included in the next backup.
Crucially, recovering any given file from one of these backups is easy. Simply browse to the Zip archive in the Files app, preview its contents and find the required file, and then copy the file to your Affinity app’s documents folder.
Initially, our shortcut will back up documents from one Affinity iPad app. Later, by taking a few extra steps, we’ll enable it to back up documents from both apps at the same time.
Choose your cloud storage
You’ll store your backups in the cloud because this protects against hardware or loss of your iPad. In this article, we’ll talk about Dropbox as a suitable destination. We’ve chosen this service because Shortcuts includes an action that can save to it.
At the time of writing, the major alternatives didn’t provide similar integration with Shortcuts. So, you’ll need to check whether your preferred service has since introduced support.
You can sign up for a free Dropbox Basic account with 2GB of storage space. Bear in mind that, depending on the number and sizes of documents backed up, this relatively modest amount of space may require you to clear out old backups more frequently so that new ones can be created.
Where to store your backups
The default save location of your Affinity iPad apps determines where your backups should be stored. You can confirm this location in each app’s General preferences.
If configured to save to your iPad’s internal storage, the shortcut can store backups on iCloud Drive or Dropbox.
However, if documents are being saved to iCloud Drive, backups will need to be stored on Dropbox. It’s good practice to keep them on a separate service to the original copies.
If you’re going to back up to Dropbox, ensure now that its app is installed and signed into an account, and that your Dropbox is accessible in the Files app’s sidebar—see Use third-party apps in this Apple Support article for instructions.
Create a shortcut
Let’s get started. Open the Shortcuts app and do the following:
- Select All Shortcuts in the app’s sidebar.
- Tap + at the top of the right pane.
- At the top left, tap the shortcut’s temporary name and replace it with Affinity Backup.
- Tap the adjacent icon and choose a glyph and a background colour. Your choices will appear in notifications displayed by the shortcut.
Identify your Affinity app’s documents folder
The shortcut’s first task is to retrieve your Affinity documents.
- In the Actions Library on the right, search for the Get Contents of Folder action.
- Tap the action to add it to your shortcut in the left pane.
- On the action in your shortcut, tap the word Folder.
- Select On My iPad or iCloud Drive to match your Affinity app’s default save location.
- Select the folder named after your Affinity app.
- Tap Done.
Filter to only the necessary files
Let’s not waste space by including all our Affinity documents in each backup. Instead, let’s back up only those files that were modified (and saved) today.
- Search for and tap the Filter Files action.
- On the action in your shortcut, tap Add Filter. The action’s description changes to read Filter Contents of Folder where File Size is exactly.
- Tap File Size and select Last Modified Date instead.
- Tap is exactly and select is today.
Note the line between the two actions. It indicates the first action’s output is passed to the second action to process.
Count the remaining files
We need to take different courses of action depending on whether or not any files were modified today.
- Append the Count action to your shortcut. It requires no changes.
- Append the If action. You’ll see it consists of three items: If, Otherwise, and End If.
- On the If item, tap Condition, and then select is.
- In the action’s updated description, tap Number, type 0, and then press Return.
When nothing has been modified
If there are no modified files, our shortcut will confirm this in a notification. This can remind you, when you next use your iPad, that you forgot to save documents the previous day. In that event, you can run the shortcut manually rather than wait for its next scheduled execution.
- Search for and drag the Show Notification action between If and Otherwise.
- Replace the notification’s default text with No Affinity documents were backed up.
When files need backing up
During the next few steps, you’ll be asked to select a magic variable.
During this selection process, magic variables are temporarily displayed after each action that produces output. Here’s how they are presented:
These variables are ‘magic’ because they make it quick and easy to specify that an action should do something with another action’s output, even if the actions are not consecutive within your shortcut.
Now, let’s get down to the real business of backing up documents.
- Add the Make Archive action between Otherwise and End If.
- On the action in your shortcut, tap Count followed by Clear Variable.
- On the action, tap Input followed by Select Magic Variable.
- Below the earlier Filter Files action, tap the Files token.
- On the Make Archive action, tap the circled arrowhead to reveal optional settings.
- Next to Archive Name, type Affinity documents, followed by a space.
- In the row of suggestions above the keyboard, tap Current Date.
- Press Return.
Save the archive
The next action you’ll add depends on where your Affinity app is configured to save documents and, consequently, where it will save your backups.
If it’s saving to On My iPad, we’ll back up to iCloud Drive. Do the following:
- Add the Save File action immediately after Make archive.
- Reveal the action’s optional settings.
- Turn off Ask Where To Save.
- In the action’s description, tap Shortcuts, followed by Replace.
- Select iCloud Drive, and then tap New Folder.
- Name the folder Affinity backups, and then tap Done.
- Tap Done.
If your Affinity app is saving to iCloud Drive, you should back up to Dropbox instead. At the time of writing, the Save File action doesn’t allow you to select Dropbox or other cloud storage that we tried. However, Dropbox provides its own alternative action, which is why we’re using this service.
In this case, do the following:
- In the Files app, create an Affinity backups folder at the top level of your Dropbox.
- In Shortcuts, add the Save Dropbox File action immediately after Make archive.
- Turn off Ask Where To Save.
- Set Destination Path to /Affinity backups.
Confirm the script finished
- Add the Show Notification action between Save File/Save Dropbox File and End If.
- Tap and then delete the action’s default text.
- In the row of suggestions above the keyboard, tap Count.
- Type a space, followed by Affinity documents backed up. Ensure iPad is online to allow upload.
If your iPad is offline when the shortcut finishes, the backup is stored locally and is only uploaded when an Internet connection is established. The same would be true of a Mac or PC backing up to the cloud.
Shortcuts doesn’t provide a simple action to confirm whether the upload process is pending or was completed, so the notification’s text acts as a reminder, when you next use your iPad, to confirm that an Internet connection has been available so that the task could finish.
Test the shortcut
That’s all the actions you need to back up a single Affinity iPad app’s documents, so tap Done (top right) to finish.
In the Affinity app whose documents you chose to back up, create and save a new document.
Return to the Shortcuts app. Select All Shortcuts and then tap the Affinity backup shortcut.
The first time the shortcut is run, iPadOS will display a series of notifications asking for various permissions, including to display notifications and save files to your Dropbox. Tap Always Allow on each so the shortcut can run without intervention in future.
When the shortcut completes, you’ll see a notification confirming how many documents were backed up.
In the Files app, browse to the folder you selected in the Save File/Save Dropbox File action.
You’ll see a Zip archive whose name includes the time at which you ran the shortcut. Long-press it, select Quick Look and then tap Preview Content to inspect the backup’s contents.
Retrieving files from a backup
To retrieve all of a backup’s contents, tap the Zip archive. After the contents have unpacked alongside the Zip archive, move them to the relevant Affinity app’s documents folder.
To retrieve an individual file, use Quick Look to preview the Zip archive’s contents, swipe to the required file, then use the Share icon to save the file back to the relevant Affinity app’s documents folder.
Back up both Affinity apps
Currently, the shortcut backs up documents from one Affinity iPad app. If you don’t require it to work for both apps, skip ahead to Automate your backups. Otherwise, do the following:
- In Shortcuts, tap the ellipsis (hellip) on the shortcut’s tile.
- Add another Get Contents of Folder action after the first one.
- On the action, tap Contents of Folder, followed by Clear Variable.
- On the action, tap Folder and select your other Affinity app’s folder.
- Next in sequence, add the List action.
- Delete the placeholder value One, and then tap Select Variable in the suggestions above the keyboard.
- Below the first Get contents of folder action, tap the magic variable labelled Contents of Folder.
- Repeat steps 6 and 7 for the placeholder value Two and the second Get contents of folder action’s magic variable. The List action now combines the output of the two preceding actions.
- On the Filter action, tap Contents of Folder, followed by Clear Variable.
- On the Filter action, tap Files, then Select Magic Variable, and then the List action’s output.
The first few actions of the shortcut should look like the screenshot below.
Test the updated shortcut
Tap Done (top right). In your second Affinity app, create and save a new document, then return to Shortcuts and run the Affinity Backup shortcut again.
This time, the Zip archive will contain both kinds of Affinity document, with visible .afphoto and .afdesign file extensions to make it clear in which app’s folder each file belongs.
Automate your backups
We want the shortcut to do its job all by itself at a particular time of day.
A suitable time might be close to your workday’s end, when you start to wind down, but leave enough time for potentially large documents to upload over your Internet connection.
- In Shortcuts’ sidebar, tap Automation, followed by Create Personal Automation.
- Tap Time of Day and set a time that works for you, e.g. 16:50.
- Tap Next, and then Add Action.
- Search for and tap the Run Shortcut action.
- On the action, tap Shortcut, select the Affinity Backup shortcut.
- Tap Next and you’ll be presented with a summary of the automation.
- On the summary, turn off Ask Before Running, tap Don’t Ask to confirm the decision, and then tap Done.
Watch out for notifications from your shortcut after its scheduled time.
You aren’t limited to automatically running the shortcut once per day. You might also schedule it to run during your lunch break, though you’ll need to remember to save documents being worked on before that time.