Regularly Back Up Karabiner Elements Configuration Files to the Cloud thumbnail

Keyboard Customization

Regularly Back Up Karabiner Elements Configuration Files to the Cloud

To prepare for emergencies, this article explains how to regularly back up Karabiner Elements configuration files to the cloud.

Modified at: 2025.7.16Posted at: 2024.11.22

Editorial Note: We earn a commission from partner links on keyboardista - English version. Commissions do not affect our editors' opinions or evaluations.

What You Want to Do

Karabiner Elements is a macOS application that allows you to change keyboard key assignments, create your own shortcuts, and even set up simple macro-like actions. As you create more settings, the configuration can become quite large. The more settings you have, the more troublesome it becomes to reconfigure everything.

When you initialize macOS or buy a new Mac, it's convenient to have a backup so you can build the same environment just by replacing the configuration files.

Overall Flow

The overall flow is as follows.

  1. Create a backup script with the standard macOS Automator app
  2. Schedule regular execution with Calendar.app

The script to be executed with Automator will regularly copy the files to the directory of the locally installed Box.com app. You can use any cloud service you like, but be aware that the directory path will differ.

After that, just set Calendar.app to execute the file regularly.

Backup Script with Automator App

Open the Automator app, then:

  1. Create New (Application)
  2. Select Utilities -> Run Shell Script
  3. Copy and paste the following into the input form
#!/bin/bash
## Karabiner configuration file directory

SOURCE_DIR="$HOME/.config/karabiner"
Box.com backup destination

BOX_BACKUP_DIR="$HOME/Library/CloudStorage/Box-Box/Backup/karabiner-elements"

## Create backup directory if it does not exist

mkdir -p "$BOX_BACKUP_DIR"
Delete old files

find "$BOX_BACKUP_DIR" -name "karabiner_backup_*.tar.gz" -type f -mtime +30 -exec rm {} ;

## Backup file name with date

TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
BACKUP_FILE="$BOX_BACKUP_DIR/karabiner_backup_$TIMESTAMP.tar.gz"
Compress and back up configuration files

tar -czf "$BACKUP_FILE" -C "$SOURCE_DIR" .

Save it.

Any location is fine as the save destination, but the default iCloud storage is probably a good choice.

Scheduled Execution with Calendar.app

Since macOS's Calendar.app can also execute files, it can serve as a simple cron.

  1. Create a new event in Calendar.app
  2. Write any event name and set it to repeat
  3. Choose "Custom" in the "Alert" settings
  4. From the pull-down, select "Open File" and choose the Automator file you just created

This will set up scheduled execution.

A downside is that your calendar may get cluttered, but if the number of scheduled actions increases, you can use short event names like "Scheduled Execution" and it won't bother you.