Jump to content

Backup Preferences — Create and restore Alfred Preferences backups


Recommended Posts

Posted

Usage


Generate a backup of your local Alfred Preferences via the start backup keyword. A macOS launchd agent will be loaded to do it daily at the time set in the Workflow’s Configuration (using the 24-hour clock format). The number of versions to keep is likewise configurable.


start.png


Restore a previous version with the restore backup keyword. It takes a few seconds to complete and restarts Alfred.


restore.png


⤓ Install on the Alfred Gallery | Source

Posted

How to Report Issues

 

Accurate and thorough information is crucial for a proper diagnosis. At a minimum, your report should include:

  • The debugger output of the failing action.
  • Your installed versions of: the Workflow, Alfred, and macOS. Be precise, don’t say “latest”.
More information is always welcome. A short video of the steps with the debugger open may help to identify the problem faster.
  • 4 weeks later...
  • 6 months later...
Posted (edited)

Can an interval be added for the number of days? I prefer to back up weekly or every x  number of days and nights every day since my preference file is 400MB each on both my Macs, and I am backing up to iCloud. 

Edited by mikedvzo
wording
Posted

That would add a bit of complexity and I worry might lead to foot guns. macOS launchd agents don’t run if your computer is turned off, so I’d hate for someone to not have a backup at a crucial time because the last one happened to be at an unlucky time and then the one they have is two weeks old or more. That’s why a time can be configured. The versioning is a secondary concern, the focus of the workflow is the backup.


You could instead reduce the number of backed up versions. If by any reason you need an older version at some point, the last 30 days of them should be available to recover.

Posted (edited)

Ok I just thought it would be an option to chose daily or weekly for people who never turn their Macs off.  Not that big of a deal will leave it daily 

Edited by mikedvzo
  • 1 month later...
Posted

New to me that you can restart Alfred while a workflow is running… I wonder if /usr/bin/osascript -l JavaScript -e 'Application("com.runningwithcrayons.Alfred").quit()' and /usr/bin/osascript -l JavaScript -e 'Application("com.runningwithcrayons.Alfred").activate()' is recommend if you want to restart Alfred if something weird is going on and you know restarting will probably fix it. 

Posted

I recommend against that. When something weird is going on, you want to reset things in the simplest, most manual way possible. You do not want to risk a strange restart not clearing whatever you’re seeing. Though I never in a decade had to restart Alfred due to something weird.

Posted
9 hours ago, vitor said:

When something weird is going on, you want to reset things in the simplest, most manual way possible

Got it. 

 

9 hours ago, vitor said:

Though I never in a decade had to restart Alfred due to something weird.

Happened several times to me this year when files or apps won't show in Alfred's default result, but a restart fixed it.

  • 4 weeks later...
Posted

Updated to 2024.1.

  • Use Universal Action to trash old backups.
  • Skip Input as Universal Action.
  • Shorter Objective-C functions.

Posted

How do you change the number of backups after the script is installed? I see the default value in the script, but I'm not sure where it is reading the value that I entered during install.

 

 

Posted
On 4/18/2024 at 12:22 PM, vitor said:

That would add a bit of complexity and I worry might lead to foot guns. macOS launchd agents don’t run if your computer is turned off, so I’d hate for someone to not have a backup at a crucial time because the last one happened to be at an unlucky time and then the one they have is two weeks old or more. That’s why a time can be configured. The versioning is a secondary concern, the focus of the workflow is the backup.


You could instead reduce the number of backed up versions. If by any reason you need an older version at some point, the last 30 days of them should be available to recover.

I thought about this more and I am trying to modify your workflow to add the Weekday argument to the LaunchAgent PLIST. From a backup perspective running a backup daily and keeping 8 copies is more unreliable than running it weekly and keeping 8 copies. If the file is corrupt you overwrite the old backups and be left with 8 corrupted versions. 

Posted
16 hours ago, mikedvzo said:

How do you change the number of backups

 

Change it in the Workflow’s Configuration. It’ll take the next time a backup fires.

 

16 hours ago, mikedvzo said:

I am trying to modify your workflow to add the Weekday argument to the LaunchAgent PLIST.

 

I recommend launchd.info for learning more.

 

16 hours ago, mikedvzo said:

From a backup perspective running a backup daily and keeping 8 copies is more unreliable than running it weekly and keeping 8 copies.

 

A weekly backup may not catch the changes you need if you need the backup in an emergency (e.g. disk failure).

 

16 hours ago, mikedvzo said:

If the file is corrupt you overwrite the old backups and be left with 8 corrupted versions. 

 

Alfred Preferences is a folder (a bundle) not a single file. And backups are never overwritten, they are trashed, so you can recover them from there or iCloud, as pointed out above.

  • 2 months later...
Posted

Can this workflow be updated to work with a non-default preferences location?  It looks like the workflow checks for the actual preferences location, but stops if it doesn't match the default path.

 

Is there a reason why a custom preferences location cannot be gzipped and saved like default location is?

Posted

If you use a custom location, you can set it to a path that syncs and does its own management of versioning. And that could interfere with the backup by e.g. ejecting files and making them unavailable offline. The workflow very deliberately only works with the default location because that’s the only way it can guarantee a correct backup.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...