Scripts for backing up and restoring your MagicMirror configuration and installed modules.
This version supports:
- Saving your full
modulesdirectory (not just Git-cloned modules) - Storing your
config.jsandcustom.css - Maintaining a list of installed modules and their GitHub source URLs (if available)
- Automatically pushing backups to a private GitHub repository
- Restoring a complete working setup using versioned git tags
To run a backup, use:
bash -c "$(curl -sL https://raw.githubusercontent.com/nerdspar/MagicMirror-backup-restore/main/mm_backup.sh)"bash -c "$(curl -sL https://raw.githubusercontent.com/nerdspar/MagicMirror-backup-restore/main/mm_backup.sh)" -p -r username/reponame -u username -e your@email.comRun this to see help:
./mm_backup.sh -hSupported flags:
| Flag | Description |
|---|---|
-s |
MagicMirror directory (default: $HOME/MagicMirror) |
-b |
Backup output directory (default: $HOME/MM_backup) |
-m |
Optional message to include with this backup/tag |
-p |
Auto-push to GitHub (requires -r, -u, and -e) |
-r |
GitHub repo name, e.g. username/reponame |
-u |
GitHub username |
-e |
GitHub email address |
To restore a backup (and all modules), use:
bash -c "$(curl -sL https://raw.githubusercontent.com/nerdspar/MagicMirror-backup-restore/main/mm_restore.sh)"Run this to see help:
./mm_restore.sh -hSupported flags:
| Flag | Description |
|---|---|
-s |
MagicMirror directory (default: $HOME/MagicMirror) |
-b |
Backup directory (default: $HOME/MM_backup) |
-f |
Fetch & restore from GitHub using latest or specific tag number |
-r |
GitHub repository name (e.g. username/repo.git) |
-u |
GitHub username |
Each backup is tagged using an incrementing number (1, 2, etc.). To list the tags:
bash -c "$(curl -sL https://raw.githubusercontent.com/nerdspar/MagicMirror-backup-restore/main/list_tags.sh)"Or view manually from the GitHub repo.
To push your backup to a private repo:
- Go to GitHub > Settings > Developer Settings
- Choose "Personal Access Tokens" → Tokens (classic)
- Generate a new token with repo (read/write) permissions
- Copy and save your token! GitHub will not show it again
- Use this token in place of a password when prompted by
git
To schedule a daily backup at 3:30 AM:
30 3 * * * bash -c "$(curl -sL https://raw.githubusercontent.com/nerdspar/MagicMirror-backup-restore/main/mm_backup.sh)" -p -r nerdspar/MagicMirror-Backup -u nerdspar -e your@email.comHappy backing up! ✨