My Macbook Air is nearing the end of its life and I’m in the process of migrating to a new machine. I’ve been wanting to learn more about bash scripting so instead of looking for existing solutions, I built a set of scripts to backup and restore my dotfiles, apps, and system settings. I thought I’d share it here in case it’s helpful to anyone.
Overview
I think of these scripts as a moving van for your Mac setup. It backs up the files and settings you care about—your dotfiles, VS Code, iTerm settings, and macOS preferences—and makes restoring them as simple as running a script.
Here’s what it can do:
1. Dotfiles Backup
Save all your important dotfiles (think .zshrc, .gitconfig, etc.), while skipping unnecessary junk like cache directories or oversized files.
2. App Settings Backup
Tooling & apps:
- Cursor: Saves your keybindings.
- VS Code: Backs up both
keybindings.jsonandsettings.json. - iTerm: Captures your configuration file, so you don’t have to manually reconfigure profiles or shortcuts.
3. System Settings Backup
MacOS system settings:
- Keyboard shortcuts
- Dock size and position
- Menu Bar configuration
- Trackpad and mouse speed
- Display settings
4. Timestamped Backups
Every backup is saved in a clean, timestamped folder for easy tracking (e.g., dotfiles/20230118_123456). No more guessing which backup is the latest.
5. Restore Scripts
When you’re ready to set up your new Mac, restoration is a breeze. Dotfiles go back to their original locations, app settings are reinstated, and system preferences are reloaded with a single script.
Usage
Step 1: Backup
On your old Mac, run the backup scripts:
./backup-dotfiles.sh
./backup-system-settings.sh
This will create a timestamped folder with all your dotfiles, app settings, and macOS preferences.
Step 2: Transfer
Move the backup folder to your new Mac (via external drive, cloud storage, or however you roll).
Step 3: Restore
On your new Mac, run the restoration scripts:
./restore-dotfiles.sh
./restore-system-settings.sh
That’s it. Your setup is back.
Retrospective
There’s something satisfying about configuring a fresh system from scratch, but these days I’ve found myself valuing efficiency over ceremony. The sooner I can get my environment set up, the sooner I can focus on meaningful work.
In hindsight, I could’ve used Time Machine to backup everything but I like this approach because it gives me more control over what I want to keep. This is especially useful when I’m low on disk space.
The code is available on GitHub, although I wouldn’t recommend using it as is. It still needs some work and is tailored to my specific setup, but I thought I’d share it here in case it’s helpful to anyone.
This project is still brewing…I’m resisting the urge to build a minimal little frontend for this—complete with toggles, size limit sliders, animations, etc. It feels like a fun excuse to learn more about SwiftUI.
Might revisit this in the future…