Backup & Restore Shortcuts
COMMENT
Backup and Restore Shortcuts
Created by @robric18
Version 1.2 tweaked by @mvan231
TEXT
{
"Shortcut Name":"Backup and Restore Shortcuts",
"Author":"Robric18",
"Current Version":"1.2",
"RoutineHub ID":"3923",
"What's New":"added mvan231's tweaks"
}

Text
SCRIPTING
Get dictionary from
Text

Dictionary
VARIABLES
Set variable
Update Info
to
Dictionary
SCRIPTING
Choose from Menu

Menu Result
SCRIPTING
Backup

Menu Result
SCRIPTING
Ask
Name of shortcut contains ... (leave blank to list all)

Provided Input
SHORTCUTS
Get my shortcuts

My Shortcuts
FILES
Filter
My Shortcuts
where
[{'class': 'filter-property', 'value': 'Name'}, {'class': 'filter-operator', 'value': 'contains'}, {'class': 'filter-benchmark inline', 'value': [{'class': 'magic', 'value': 'Provided Input', 'glyph': '', 'UUID': '14EF7745-460C-4073-B1E7-BA6D7063CAF2'}]}]

Files
SCRIPTING
Choose from Menu

Menu Result
SCRIPTING
No

Menu Result
SCRIPTING
Choose from
Files
Prompt
Select shortcuts to backup

Chosen Item
SCRIPTING
Yes

Menu Result
SCRIPTING
Choose from
Files
Prompt
Select shortcuts to backup

Chosen Item
SCRIPTING
End Menu

Menu Result
DOCUMENTS
Create Folder
Path
[{'value': '/Shortcuts/', 'class': 'text'}, {'value': 'Backups/', 'class': 'text'}, {'class': 'magic', 'value': 'Current Date', 'glyph': 'assets/cat/Date.svg', 'UUID': ''}]
DOCUMENTS
Save
Menu Result
Destination Path
[{'value': '/Shortcuts/', 'class': 'text'}, {'value': 'Backups/', 'class': 'text'}, {'class': 'magic', 'value': 'Current Date', 'glyph': 'assets/cat/Date.svg', 'UUID': ''}]Overwrite If File Exists

Saved File
DOCUMENTS
Get File
File Path
/Shortcuts/example.txt

File
TEXT
File

Text
SCRIPTING
If
Text
contains
Current Date
TEXT
File

Text
SCRIPTING
Otherwise
SCRIPTING
If
File
has any value
TEXT
Current Date
File

Text
SCRIPTING
Otherwise
TEXT
Current Date

Text
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
DOCUMENTS
Save
If Result
Destination Path
/Shortcuts/Backups/ListOfBackupFolders.txtOverwrite If File Exists

Saved File
SCRIPTING
Show alert
Shortcuts Backed Up
Title
Shortcuts Backed Up
SCRIPTING
Restore

Menu Result
DOCUMENTS
Get File
File Path
/Shortcuts/example.txt

File
TEXT
File
Choose Folder

Text
TEXT
Split
Text
by
New Lines

Split Text
SCRIPTING
Choose from
Split Text
Prompt
Pick date of backup you want to retrieve

Chosen Item
SCRIPTING
If
Chosen Item
is
Choose Folder
MISSING
file.select Under Construction
SCRIPTING
Otherwise
DOCUMENTS
Get File
File Path
/Shortcuts/example.txt

File
FILES

Files
SCRIPTING

Chosen Item
SCRIPTING
End If

If Result
TEXT
1) When you press OK a new screen will open asking you to create an iCloud link. Press "Create Link"
2) You will be taken to a screen with the link. Press "Get Shortcut"
3)You will be brought to the Add Shortcut page in shortcuts. You can change the name of the shortcut here if you desire. Scroll to the bottom of the page and press "Add Untrusted Shortcut"
4) Your backed up shortcut will now be restored to Shortcuts.

Text
SCRIPTING
Show alert
Preparing to Restore Shortcut
Title
Preparing to Restore Shortcut
DOCUMENTS
Get link to
If Result

Link to File
SAFARI
Open
Link to File
SCRIPTING
End Menu

Menu Result
URL
https://routinehub.co/api/v1/shortcuts/
Update Info
/versions/latest

URL
NETWORK
Get contents of
URL
Options Under Construction

Contents of URL
SCRIPTING
Get dictionary from
Contents of URL

Dictionary
SCRIPTING
Get
Value
for
Version
in
Dictionary

Dictionary Value
SCRIPTING
If
Dictionary Value
is greater than
Update Info
TEXT
You have version
Update Info
of
Update Info
installed.
An update to version
Version
is available.
If you wish to update press OK.
Otherwise press Cancel.
What's New in this version?
Notes

Text
SCRIPTING
Show alert
Update Available
SAFARI
Open
URL
SCRIPTING
Otherwise
SCRIPTING
End If

If Result
DOCUMENTS
Make
tar.bz2
archive from
Menu Result
Archive Name
[{'class': 'magic', 'value': 'Current Date', 'glyph': 'assets/cat/Date.svg', 'UUID': ''}]

Archive
DOCUMENTS
Save
Archive
Destination Path
[{'value': '/Shortcuts/', 'class': 'text'}, {'value': 'Backups/', 'class': 'text'}, {'class': 'magic', 'value': 'Current Date', 'glyph': 'assets/cat/Date.svg', 'UUID': ''}]Overwrite If File Exists

Saved File
DOCUMENTS
Showcuts