/backupstreamdeck

Mac shell script to backup Stream Deck files

Primary LanguageShellThe UnlicenseUnlicense

backupstreamdeck

TL;DR: Mac shell script to backup Stream Deck configuration files.

(Note: This script is not produced by Elgato, makers of the Stream Deck. It is not endorsed or recommended by them. It is made by some random guy on the Internet who likes the Stream Deck. See additional disclaimer (below) and License for more.)


This script backs up two things:

	"$HOME/Library/Preferences/com.elgato.StreamDeck.plist"

	"$HOME/Library/Application Support/com.elgato.StreamDeck/"

The first is the preferences file that the app uses.

The second includes all of the custom profiles that you have, most likely, worked very hard to hand-craft and personalize. (Those are in "$HOME/Library/Application Support/com.elgato.StreamDeck/ProfilesV2/".)

Customization

BACKUP_TO="$HOME/Desktop"

How to Run

I recommend downloading backupstreamdeck.sh and moving it to /usr/local/bin/ and then making it executable:

	chmod 755 /usr/local/bin/backupstreamdeck.sh

If you have never installed any other Unix utilities you may need to create /usr/local/bin/ using:

	sudo mkdir -p /usr/local/bin/

	sudo chown "$LOGNAME" /usr/local/bin/

Once installed, you can run the command any time by entering backupstreamdeck.sh in Terminal. But, of course, I recommend that you automate this, because how likely is it that you will remember to do that?

Keyboard Maestro and launchd

I have a Keyboard Maestro macro which runs this script every time the Stream Deck app quits.

However, I sometimes go a long time without quitting the app or rebooting my Mac, so I decided to have an automated backup that runs: 1) whenever I log in to my Mac and 2) every 24 hours after that.

To do that, I use launchd which is a built-in part of macOS to run things at certain times.

If you want to do this, download the file com.tjluoma.backupstreamdeck.plist and save it to "$HOME/Library/LaunchAgents/" (you may need to created that folder).

Note: When you download the file, make sure that your web browser does not change the extension. It must end in .plist or else it will not work.

Once you have it in the right place, you need to tell launchd to "load" the new file. Copy/paste this command into Terminal:

launchctl load "$HOME/Library/LaunchAgents/com.tjluoma.backupstreamdeck.plist"

and hit Enter. If you don’t see anything, that means it worked. If you get an error message, make sure the file name is correct and try again. (Also make sure that you are using straight " and not “smart” or “curly” quotes.)

What if I want to back it up more or less often using launchd ?

You can change the time between backups by editing this part of the com.tjluoma.backupstreamdeck.plist file:

	<key>StartInterval</key>
	<integer>86400</integer>

The 86400 is the number of seconds in 24 hours. If you set it to 3600 then it would back up every hour. If you set it to 21600 it would back up every 6 hours. And so on.

If you edit the file after you load it, you will need to unload it:

launchctl unload "$HOME/Library/LaunchAgents/com.tjluoma.backupstreamdeck.plist"

and then load it again:

launchctl load "$HOME/Library/LaunchAgents/com.tjluoma.backupstreamdeck.plist"

Note! If you do edit the com.tjluoma.backupstreamdeck.plist file, be sure you are using a text editor such as TextEdit or BBEdit, not Pages, Microsoft Word, etc. Actually, I highly recommend the excellent app LaunchControl for managing launchd plists. It will even show you the "translation" of seconds to minutes/hours/etc, and it will help you load/reload the .plist file when needed.

How to restore

If you want to move these files to another computer or if you need to use them to restore a "corrupted" installation, step number one is to make 100% sure that the Stream Deck app is not running.

Trying to replace these files while the app is running is a terrible idea, akin to trying to replace the chain on your bicycle as you are riding your bicycle. Sure, it might be OK, but odds are good that it will not be OK.

To Use the Backup plist

  1. Make sure the app is not running.

  2. Go to ~/Library/Preferences/

  3. If there is an existing com.elgato.StreamDeck.plist file, rename it to something like com.elgato.StreamDeck.plist.OLD and move it somewhere like the Desktop.

  4. Copy the .plist file you want to use to ~/Library/Preferences/ and make sure it is named com.elgato.StreamDeck.plist

To Use the Backup Preferences Folder

  1. Make sure the app is not running.

  2. Go to ~/Library/Application Support

  3. If there is an existing com.elgato.StreamDeck folder, rename it to something like com.elgato.StreamDeck.OLD and move it to the Desktop or somewhere else.

  4. Uncompress the backup file, and rename it to com.elgato.StreamDeck

Questions/Comments/FAQs/etc

“These files are cluttering up my Desktop! How can I have them saved somewhere else?!?”

I use Hazel to move them from my Desktop to somewhere else, but if you want them to go somewhere else directly, edit the backupstreamdeck.sh script using a text editor (such as TextEdit, BBEdit, not Pages or Word) and change this line:

	BACKUP_TO="$HOME/Desktop"

For example, if you had a folder called "Stream Deck Backups" in your Home folder, you would change that to

	BACKUP_TO="$HOME/Stream Deck Backups"

Note that if your designated BACKUP_TO does not exist, the script will fall back to the Desktop. And if the Desktop folder doesn’t exist (which I don’t even think is possible, but anyway…) then it will fall back to $HOME. If your $HOME doesn’t exist, well, you have more problems than I can help with.

No Warranty Expressed or Implied

Use entirely at your own risk.

This works… as far as I know… and should definitely not reformat your hard drive and post your taxes and nude selfies to the Dark Web, but if it does that or anything else, well, as the man said…

"It's not my fault."

See License for complete details about my complete lack of culpability and responsibility.