𝗕𝗔𝗥𝗧
a full-featured Backup, Archive, and Restore Tool
WARNING: In the following Dictionary action, the 'MyName' item must match the name of this shortcut.
BART [default]
[𝘋𝘰 𝘯𝘰𝘵 𝘤𝘩𝘢𝘯𝘨𝘦 𝘵𝘩𝘦 𝘤𝘰𝘯𝘵𝘦𝘯𝘵𝘴 𝘰𝘧 𝘵𝘩𝘪𝘴 𝘤𝘰𝘮𝘮𝘦𝘯𝘵.]
~~~ Start of 𝗖𝗼𝗻𝗳𝗶𝗴𝘂𝗿𝗮𝘁𝗶𝗼𝗻 𝗣𝗮𝗿𝗮𝗺𝗲𝘁𝗲𝗿𝘀 ~~~
The following can be changed manually or by using 𝗦𝗲𝘁𝘁𝗶𝗻𝗴𝘀->𝗖𝘂𝘀𝘁𝗼𝗺𝗶𝘇𝗲 𝗦𝗵𝗼𝗿𝘁𝗰𝘂𝘁
Segregate Backup Files* by iOS Device
┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈
0 = No [default & recommended if 'iCloud Sync' is ON]
1 = Yes [recommended if using multiple devices and not syncing shortcuts via 'iCloud Sync']
*Backup Files are created using "Snapshot", "Backup", and "Archive" menu options.
~~~ End of 𝗖𝗼𝗻𝗳𝗶𝗴𝘂𝗿𝗮𝘁𝗶𝗼𝗻 𝗣𝗮𝗿𝗮𝗺𝗲𝘁𝗲𝗿𝘀 ~~~
Remove any problematic characters that could appear in the Device Name.
As Root is defined below, all backups for all iOS devices (for a given iCloud account) will be grouped together.
As an alternative, Root could be set to: MyName/Device Name (clean).
~~~ Start of an additional 𝗖𝗼𝗻𝗳𝗶𝗴𝘂𝗿𝗮𝘁𝗶𝗼𝗻 𝗣𝗮𝗿𝗮𝗺𝗲𝘁𝗲𝗿 ~~~
The following can be changed manually but since they will be rarely changed by most users, they are not changed via 𝗦𝗲𝘁𝘁𝗶𝗻𝗴𝘀->𝗖𝘂𝘀𝘁𝗼𝗺𝗶𝘇𝗲 𝗦𝗵𝗼𝗿𝘁𝗰𝘂𝘁
Optionally add to the List action below by including any folders (aka 'Restore Folders') in /iCloud Folder/Shortcuts/ (e.g., 'Shortcut Backups/') that contain shortcuts files. This list, combined with items in 'Restore Folders.txt', is used by the 'Restore (from selected folder)' Operation.
Since the first two items are folders used within this shortcut, it is strongly recommended that you keep these two list items.
Note 1: Folder entries in the List action below are case-sensitive.
Note 2: Include a trailing slash (/) in any folders added to the list.
~~~ End of an additional 𝗖𝗼𝗻𝗳𝗶𝗴𝘂𝗿𝗮𝘁𝗶𝗼𝗻 𝗣𝗮𝗿𝗮𝗺𝗲𝘁𝗲𝗿 ~~~
Constants
mode = null | interactive | settings | input
task = null | skip | backup | archive | restore
source = null | My Shortcuts | zip file | folder
Set .T so that type checks can be language agnostic.
Initialize global variables
⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️
Check Shortcut Input for passed information from another shortcut.
⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️
Check network status.
⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️
Create the main shortcut folders.
⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️
Update the settings file.
Determine if the 'Restore Folders' list used previously includes some entries that are not in the current folder list. This would normally occur if: 1) the user added custom folders to the list, 2) after the folder additions, the user installed a new version of this shortcut.
Combine the folders in the Folder List (above) with the folders in the folders text file.
Based on the folder count already in the text file (if any) and the folder count that the user selected above, compose the appropriate alert.
⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️
Check the settings file for 'Shortcuts to Restore'. If shortcuts are included, present an option to restore an item in the list.
Main Menu (in Contact format)
There are two situations when the main menu should not be displayed:
1] mode = settings : above there was a check in the settings file for 'Shortcuts to Restore'. If one or more was found and the user specified to restore one, then the main menu will not be presented.
2] mode = input : if this shortcut is run from another and passed a Dictionary via the 'Shortcut Input.'
Variables (that will depend on the 'Selected Menu Item'
select = 0 | 1
task = backup | archive | restore
source = shortcuts in My Shortcuts | shortcuts in zip or folder
shortcut = specified or selected shortcut
shortcuts = specified or selected shortcuts
When mode = input, operation is set via Input Dictionary.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Use the 'Repeat for each' to avoid the prompts to confirm.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Restore from a selected folder.
Build a menu that, for each folder, includes a folder icon, folder name, and shortcut count.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Restore from a zip archive.
Check to determine if the zip had been previously extracted to the named unarchived folder.
Update Settings if the 'Unarchive Subfolder' is not already included included in the 'Unarchive Subfolders' dictionary (Key = subfolder name, Value = file count).
If the 'Unarchive Subfolder' is not already in the 'Unarchive Subfolders (Keys)' list is the settings, add it to the list.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Restore from an unarchive folder
Open the settings file and read the 'Unarchive Folders'. If any of the folders are no longer present (or if any of the folders have not shortcuts -- in which case, delete the subfolder), update the settings file.
Ideally it would be nice to delete the empty folder, but as of 13.3 beta 3 (17C5046a) there is no way to delete a folder in shortcuts.
Delete Key: Unarchive Folders
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Restore One from file browse
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Replace smart quotes, smart single quotes, en dash, and em dash.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
▫️🟢🟢 🟢▫️🟢 🟢🟢▫️
🟢▫️▫️ 🟢▫️🟢 🟢▫️🟢
▫️🟢▫️ 🟢▫️🟢 🟢🟢▫️
▫️▫️🟢 🟢▫️🟢 🟢▫️🟢
🟢🟢▫️ 🟢🟢🟢. 🟢🟢▫️
⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️
Select a subset of shortcuts.
𝗹𝗲𝗮𝘃𝗲 𝗯𝗹𝗮𝗻𝗸 ~ 𝗍𝗈 𝗌𝖾𝗅𝖾𝖼𝗍 𝖿𝗋𝗈𝗆 𝖺𝗅𝗅 𝗌𝗁𝗈𝗋𝗍𝖼𝗎𝗍𝗌, 𝗮𝗹𝗹 𝗉𝗋𝖾𝗌𝖾𝗅𝖾𝖼𝗍𝖾𝖽
𝗮 𝘀𝗽𝗮𝗰𝗲 ~ 𝗍𝗈 𝗌𝖾𝗅𝖾𝖼𝗍 𝖿𝗋𝗈𝗆 𝖺𝗅𝗅 𝗌𝗁𝗈𝗋𝗍𝖼𝗎𝗍𝗌, 𝗻𝗼𝗻𝗲 𝗉𝗋𝖾𝗌𝖾𝗅𝖾𝖼𝗍𝖾𝖽
𝙩𝙚𝙭𝙩 ~ 𝗍𝗈 𝗌𝖾𝗅𝖾𝖼𝗍 𝖿𝗋𝗈𝗆 𝗌𝗁𝗈𝗋𝗍𝖼𝗎𝗍𝗌 𝗐𝗂𝗍𝗁 𝖺 𝗇𝖺𝗆𝖾 𝖼𝗈𝗇𝗍𝖺𝗂𝗇𝗂𝗇𝗀 𝙩𝙚𝙭𝙩.
One or more matches.
▫️🟢🟢 🟢▫️🟢 🟢🟢▫️
🟢▫️▫️ 🟢▫️🟢 🟢▫️🟢
▫️🟢▫️ 🟢▫️🟢 🟢🟢▫️
▫️▫️🟢 🟢▫️🟢 🟢▫️🟢
🟢🟢▫️ 🟢🟢🟢. 🟢🟢▫️
Seconds for iCloud Refresh
(This number produces a delay below. 'Repeat 1 time' loop below for more information.)
Counts below can sometimes be incorrect if there is no delay between writing the files (action above) and counting the entries in the folder (below this 'Repeat 1 time' loop.)
All of the statements in the following Repeat loop (1 time) are added to maximize the probability that the counts are correct when the 'full accounting' is reported.
If the accounting below is not reliable try increasing 'Backup (secs for iCloud refresh)' (a Number in the main shortcut Dictionary).
▫️🟢🟢 🟢▫️🟢 🟢🟢▫️
🟢▫️▫️ 🟢▫️🟢 🟢▫️🟢
▫️🟢▫️ 🟢▫️🟢 🟢🟢▫️
▫️▫️🟢 🟢▫️🟢 🟢▫️🟢
🟢🟢▫️ 🟢🟢🟢. 🟢🟢▫️
▫️🟢🟢 🟢▫️🟢 🟢🟢▫️
🟢▫️▫️ 🟢▫️🟢 🟢▫️🟢
▫️🟢▫️ 🟢▫️🟢 🟢🟢▫️
▫️▫️🟢 🟢▫️🟢 🟢▫️🟢
🟢🟢▫️ 🟢🟢🟢. 🟢🟢▫️
Add action (with null) is a work-around since the iOS 13 version of the Shortcuts app no longer has a 'Get Variable' action.
Determine if a restore alert should be displayed based on the number of days that have elapsed since it was last displayed.
Update the settings file (in a list named: Shortcuts to Restore) with shortcuts 2 to N. During the next run of this shortcut (before the main menu is displayed), this shortcut will present the option to restore shortcut 2.
⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️
--- END OF SUBS
⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️
If mode is input, exit the shortcut passing a Dictionary of shortcut metadata and run information.
⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️
Determine if a periodic check for update should be done based on the number of days that have elapsed since the last check.
0 = never check
n = days that must elapse before the check is made
𝗧𝗵𝗲 𝗳𝗼𝗹𝗹𝗼𝘄𝗶𝗻𝗴 𝗰𝗵𝗲𝗰𝗸 𝗳𝗼𝗿 𝘂𝗽𝗱𝗮𝘁𝗲 𝗮𝗰𝘁𝗶𝗼𝗻𝘀 𝗮𝗿𝗲 𝗮𝗱𝗮𝗽𝘁𝗲𝗱 𝗳𝗿𝗼𝗺:
[Eᴍʙᴇᴅ-ᴀ-Uᴘᴅᴀᴛᴇ], https://routinehub.co/shortcut/2672
There is no network connection, thus an update check could not be made.
Array
Set 'Check for Update' in the settings file to today's date. During subsequent runs of this shortcut, this saved setting and 'Check for Update.Elapsed Days' will be used to determine if a periodic automatic update check should be executed.
Array