BART • a full-featured Backup, Archive, and Restore Tool

Automators,

You might find this shortcut useful. I’ve posted it on RoutineHub.co.

BART
a full-featured Backup, Archive, and Restore Tool

Post and comments are also available on reddit /shortcuts.

2 Likes

BARTa full-featured Backup, Archive, and Restore Tool

Overview

BART is a shortcut that can back up, archive, and restore shortcuts in the Shortcuts app Library, also known as My Shortcuts. It is designed to be full-featured, yet simple and fast to use. In fact, most of the information below can be easily discovered by simply running the shortcut. However if you prefer to read instructions and/or learn some of the finer points of BART, the following is for you.


So what’s the point?

Short answer: It’s always good to back up your work!

Long answer: Stuff happens! On occasion, the iOS Shortcuts app will display an error indicating that the database is corrupt. If iCloud Sync (one of the Shortcuts app settings) is set, the Shortcuts app attempts to recreate My Shortcuts after the error dialog is dismissed. Depending on the circumstances, this restoration can range from a complete recovery to a complete loss of all of the shortcuts in My Shortcuts. If not a complete recovery, shortcut backups are indispensable. Backups are also valuable during more common and frequent events, e.g., if a shortcut is mistakenly modified or deleted.

In addition to shortcut protection, backups can be employed to manage shortcuts. For example, a user might find a group of shortcuts that are useful occasionally, but not want to clutter My Shortcuts with these rarely used shortcuts. Such shortcuts could be archived and restored when needed.


BART Main Menu

This section includes a short description for each Shortcut Operation on the BART main menu.

Save Snapshot of My Shortcuts saves a copy of all shortcuts in My Shortcuts to the snapshot folder: /iCloud Drive/Shortcuts/BART/Snaphot/. All files previously in this folder are deleted before the shortcuts are copied to this folder. This is the fastest and simplest way to back up My Shortcuts.

Back Up Selected saves copy of one or more selected shortcuts in My Shortcuts to the backup folder: /iCloud Drive/Shortcuts/BART/Backup/. Shortcuts files in the folder are written over if the selection includes shortcuts with the same names.

Shortcuts previously backed up to the backup folder and later deleted from My Shortcuts are not automatically deleted from the backup folder. Thus over time, the backup folder will likely contain a superset of shortcuts from My Shortcuts.

Archive All creates a zip archive of the shortcuts in My Shortcuts and saves the file to the archive folder: /iCloud Drive/Shortcuts/BART/Archive/. The archive is named based on the date/time and #x (where x is the number of shortcuts in the new zip archive). For example, the following archive would include 102 shortcuts: 2019-12-10-073522_#102.zip.

Archive Selected creates a zip archive of one or more selected shortcuts in My Shortcuts and saves the file to the archive folder: /iCloud Drive/Shortcuts/BART/Archive/. The archive is named based on the date/time and either: a) #x (where x is a number 2 to n indicating the number of contained shortcuts), or b) shortcutname (if only one shortcut is selected). For example, the following archive would include 102 shortcuts: 2019-12-10-073522_#102.zip and the following would include one shortcut named xyz: 2019-12-10-073522_xyz.zip.

Restore (from a selected folder) displays a list of specified folders that contain shortcut files. Once the user selects one of the folders, a second selection list is displayed with all of the shortcuts within the folder. If the user selects one or more of these shortcuts, they are restored to My Shortcuts.

By default, the folder list contains two folders in /iCloud Drive/Shortcuts/:

  • BART/Snapshot/
  • BART/Backup/

Any other folder in /iCloud Drive/Shortcuts/ can be added to the list by adding it to a List action within BART. This could be useful for users that have used another means to backup and/or organize shortcut backup files. Note: All folder entries are case-sensitive!

Restore (from a zip archive) displays a list of zip archives in the archive folder: /iCloud Drive/Shortcuts/BART/Archive/. If a user selects one of the zip archives, the file is unzipped into a new subfolder in the unarchive folder: /iCloud Drive/Shortcuts/BART/Unarchive/. For example, if the user selected 2019-12-10-073522_#102.zip the archive would be unzipped into the following: /iCloud Drive/Shortcuts/BART/Unarchive/2019-12-10-073522_#102/. After the archive is unzipped, a second selection list is displayed with all of the shortcuts within the subfolder. If the user selects one or more shortcuts, they are restored to My Shortcuts.

Restore (from an unarchive folder) displays a list of subfolders in the unarchive folder. If a user selects one of the subfolders, a second selection list is displayed with all of the shortcuts within the subfolder. If the user selects one or more shortcuts, they are restored to My Shortcuts.

This restoration operation would be used to recover a shortcut that was previously archived (using Archive All or Archive Selected) and then subsequently unzipped using the Restore (from a zip archive) operation.

Restore One (from a file browse) will open a file selection dialog to allow the user to select a shortcut file. The selected shortcut will be restored to My Shortcuts.

This restoration operation would likely be used infrequently as it is intended for files that were backed up prior to using BART. This method has the advantage of being more flexible in that the shortcut file can be located anywhere, not limited to /iCloud Drive/Shortcuts/. The disadvantage of this method is that only one shortcut can be selected per file browse.

Help displays this information.

Check for Updates causes BART to automatically check for an updated version of itself. Note that this check will occur every 7 days even if this menu option is never selected.


Shortcut and Workflow Files

Shortcut files saved to iCloud Drive by BART include a shortcut extension (e.g., xyz.shortcut).

The Shortcuts app is an updated version of Workflow, a third-party iOS app that Apple acquired in 2017. Although similar, this app included workflows, not shortcuts. Workflow files included a wflow extension and, like shortcut files, can be restored using BART.


Restoring Shortcuts

With iOS 13.x, the Shortcuts app cannot restore/import a shortcut file directly from iCloud Drive. (This limitation did not exist with the iOS Workflow app, but may have been added by Apple for security reasons.) Therefore to restore/import a shortcut, the shortcut file must first be uploaded to iCloud (in a public area established by Apple that is reserved for shortcuts). Once uploaded, a shortcut file can then be restored/imported within Safari by opening an iCloud link (to the uploaded shortcut file).

BART automates the process described above. However once the link is opened in Safari, a user must complete the final step by selecting blue Get Shortcut button that appears on the shorcut’s Safari page. Because of a limitation with the Shortcuts app, this final step cannot be completed if a shortcut is still running. Due to these constraints, only one shortcut can be automatically restored/imported for each run of BART (or any similar restoration shortcut). Therefore if the user selects more than one shortcut to restore, the first one will be restored during that run of BART; shortcuts 2 to n will be queued up and ready to be restored, one at a time, with each subsequent run of BART.


Optional Management of iCloud Folders

As mentioned above, snapshot, backup, and archive files are saved to /iCloud Drive/Shortcuts/ subfolders, specifically BART/Snapshot/, BART/Backup/, and BART/Archive/, respectfully. In general, the contents of these folders are managed automatically by BART, but in some cases the contents can be managed manually using the iOS Files app or the macOS Finder. Specifically:

  • Shortcuts no longer needed but previously backed up to BART/Backup/ can be manually deleted.

  • Shortcuts files (*.shortcut), and even old Workflow files (*.wflow), can be manually added to BART/Backup/. These shortcuts (or workflows) can be restored using the Restore (from a selected folder) operation.

  • As an alternative to the above bullet, old Shortcuts app (or Workflow app) backups could be managed in a separate folder(s) within /iCloud Drive/Shortcuts/. Files in this folder(s) can be restored using :

    1. Restore One (from a file browse).
    2. Restore (from a selected folder). In this case, the /iCloud Drive/Shortcuts/ subfolder(s) would need to be added to the folder list using the List action within the shortcut. This list appears near the top of BART and includes a preceding comment. Note: All folder entries are case-sensitive!
  • Unneeded zip archive files in BART/Archive/ can be deleted.

  • Older zip archives that include shortcuts (or even workflows), that may have been created by some other means, can be manually added to BART/Archive/. BART could then be used to process these archives just as it does for the archives that it creates.

  • Unarchive subfolders in BART/Unarchive/ can be deleted (e.g., BART/Unarchive/2019-12-12-131131_#109). Also, shortcuts no longer needed can be individually deleted from these subfolders.

  • Note: Shortcuts files can be copied from BART/Snapshot/, but since this folder is automatically managed by BART, the folder contents should not be modified.


Running BART From Another Shortcut

BART can be optionally started from another shortcut. This is also known as running BART in Input mode. This mode is useful because routine tasks can be automated and run consistently and quickly without user interaction with the BART main menu.

Note: The following information in this section will be easier to understand if the four shortcuts included at the end of the section are first downloaded and inspected.

To run BART in this mode, the calling shortcut needs two actions: Dictionary and Run Shortcut.

This Dictionary information is used by BART to determine the desired Operation (in leui of user interaction with the BART main menu). Depending on the BART Operation, the Dictionary action must have one or two Dictionary Items: [item 1: Key = Operation] or [item 1: Key = Operation; item 2: Key = Shortcut].

The following one-item BART Operations are supported:

  • Dictionary[item 1: Key = Operation, Text = Snapshot]
  • Dictionary[item 1: Key = Operation, Text = Archive All]

And the following two-item BART Operations are also supported:

  • Dictionary[item 1: Key = Operation, Text = Back Up; item 2: Key = Shortcut, Text = shortcut_name]
  • Dictionary[item 1: Key = Operation, Text = Archive; item 2: Key = Shortcut, Text = shortcut_name]]

As mentioned above, the above Dictionary action must precede the Run Shortcut action (specifically Run[BART]).

Note 1: In the second group of BART Operations, a third key [Key = Shortcuts] can replace the second key [Key = Shortcut]. This must be employed when backing up or archiving more than one shortcut with a single Dictionary/Run[BART] pair. In this case, the Dictionary item must be an Array, with Key = Shortcuts, and the shortcut_names are entered as separate Text array items.

Note 2: The functionality in this section is much more complicated to describe than to actually use. The following example shortcuts demonstrate each of the four operations discussed above:

  1. Call BART (Snapshot)
  2. Call BART (Archive All)
  3. Call BART (Back Up)
  4. Call BART (Archive)

continued on RoutineHub…

5 Likes

Word of caution about importance of Shortcuts backups. This morning I launched Shortcuts on an older iPhone on which I hadn’t launched Shortcuts in a while. The device is up to date with all software. I did not realize that the Shortcuts on this device were somehow out of synch with iCloud.

Unfortunately, all of my old shortcut info on this device overwrote iCloud and, of course, synced to all of my other devices. I’ve lost all color/icon changes. More importantly, I’ve lost any edits that I made to shortcuts that were on the old device. I had many… lots of stuff updated over the last few months with enhancements, better techniques, use of Toolbox Pro actions, etc etc. All lost.

I know nothing about BART, but using this thread as both warning and reminder that it is worth having a backup no matter the method you use. — jay