Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

macOS Menu Bar Backup Widget

! Written entirely by AI - use at your own risk !

A lightweight menu bar backup widget for macOS that uses rsync to backup your files to a remote server (Hetzner Storage Box compatible). Built with SwiftBar for simplicity.

Menu Bar Screenshot

Features

  • Menu bar widget showing days since last backup with color-coded status
  • Multiple backup jobs - backup your Mac + external drives
  • Smart drive detection - external drive backups only run when connected
  • Live progress view - option to see rsync output in Terminal
  • Handles macOS permission quirks - treats protected system files gracefully
  • Hetzner Storage Box compatible - works with port 23 and SFTP-based SSH

Menu Bar Status

Icon Color Meaning
✓ 0d Green Backed up today
✓ 2d Green Backed up 2 days ago
⏱ 5d Yellow Getting stale (3-7 days)
⚠ 10d Red Overdue (> 7 days)
⟳ ... Blue Backup in progress
○ -- Gray Never backed up

Requirements

  • macOS 12+ (tested on Monterey)
  • SwiftBar - menu bar app
  • SSH access to your backup server
  • rsync (built into macOS)

Installation

1. Install SwiftBar

brew install --cask swiftbar

2. Create config directory and copy files

# Create config directory
mkdir -p ~/.config/backup

# Copy scripts
cp scripts/backup-runner.sh ~/.config/backup/
cp scripts/setup-ssh.sh ~/.config/backup/
cp scripts/backup.conf.template ~/.config/backup/backup.conf

# Make scripts executable
chmod +x ~/.config/backup/backup-runner.sh
chmod +x ~/.config/backup/setup-ssh.sh

# Copy SwiftBar plugin
cp swiftbar/backup.1d.sh ~/Library/Application\ Support/SwiftBar/
chmod +x ~/Library/Application\ Support/SwiftBar/backup.1d.sh

3. Configure your backup

Edit ~/.config/backup/backup.conf:

# Your server details
REMOTE_USER="your_username"
REMOTE_HOST="your_server.your-storagebox.de"
SSH_PORT=23  # Use 22 for regular servers, 23 for Hetzner Storage Box

# Backup job 1: Your home folder
JOB1_ENABLED=true
JOB1_NAME="Mac Home"
JOB1_SOURCE="$HOME"
JOB1_REMOTE_PATH="/home/computer-backup"

# Backup job 2: External drive (optional)
JOB2_ENABLED=true
JOB2_NAME="External Drive"
JOB2_SOURCE="/Volumes/MyDrive"
JOB2_REMOTE_PATH="/home/external-backup"

4. Set up SSH key authentication

~/.config/backup/setup-ssh.sh

This will:

  • Generate an SSH key (if you don't have one)
  • Copy it to your server (you'll enter your password once)
  • Test the connection
  • Create remote backup directories

5. Launch SwiftBar

Open SwiftBar and when prompted, select this folder as your plugins directory:

~/Library/Application Support/SwiftBar/

Usage

Click the menu bar icon to:

  • Backup Now - run backup silently in background
  • Backup Now (show progress) - open Terminal with live rsync output
  • Edit Configuration - open config file
  • View Backup Log - see recent backup activity

Customization

Change refresh interval

Rename the plugin file:

  • backup.1d.sh - check daily (default)
  • backup.1h.sh - check hourly
  • backup.30m.sh - check every 30 minutes

Add more backup jobs

Edit backup.conf to add JOB3**, JOB4**, etc., then update backup-runner.sh to include them.

Customize excludes

Edit the EXCLUDE_PATTERNS array in backup.conf to skip specific files/folders.

How It Works

┌─────────────────────┐
│   SwiftBar Plugin   │  ← Shows status in menu bar
│   (backup.1d.sh)    │     Reads state file daily
└─────────┬───────────┘
          │ User clicks "Backup Now"
          ▼
┌─────────────────────┐
│  backup-runner.sh   │  ← Runs rsync for each job
│                     │     Updates state file
└─────────┬───────────┘
          │ rsync over SSH
          ▼
┌─────────────────────┐
│   Remote Server     │  ← Your Hetzner Storage Box
│   (Hetzner, etc.)   │     or any SSH server
└─────────────────────┘

Troubleshooting

"Operation not permitted" errors

This is normal! macOS protects certain Library folders (Safari, Accounts, etc.). Your important files are still being backed up. The script treats these as warnings, not failures.

External drive not backing up

Make sure the drive is mounted and the path in JOB2_SOURCE matches exactly. Check with:

ls /Volumes/

SSH connection fails

  1. Verify your server details in backup.conf
  2. For Hetzner Storage Box, ensure SSH_PORT=23
  3. Re-run setup-ssh.sh to reset SSH keys

Backup stuck at "running"

If a backup was interrupted, clear the lock:

rm ~/.config/backup/backup.lock

File Locations

File Purpose
~/.config/backup/backup.conf Your configuration
~/.config/backup/backup.state Last backup status
~/.config/backup/backup.log Backup logs
~/.config/backup/backup.lock Prevents concurrent runs
~/Library/Application Support/SwiftBar/backup.1d.sh Menu bar plugin

License

MIT License - feel free to use and modify.

Credits

Built with SwiftBar and good old rsync.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages