Created
July 16, 2025 03:43
-
-
Save koriym/8a6e4bbf786ca35d1032201275a6f221 to your computer and use it in GitHub Desktop.
Backup brew settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # バックアップファイルの保存先 | |
| BACKUP_DIR=~/brew-backup | |
| mkdir -p "$BACKUP_DIR" | |
| echo "📦 Saving installed formulae..." | |
| brew list > "$BACKUP_DIR/formula-list.txt" | |
| echo "🧃 Saving installed casks..." | |
| brew list --cask > "$BACKUP_DIR/cask-list.txt" | |
| echo "🌐 Saving tapped repositories..." | |
| brew tap > "$BACKUP_DIR/tap-list.txt" | |
| echo "✅ Backup complete. Files saved in $BACKUP_DIR" | |
| # 復元用スクリプト作成 | |
| cat <<'EOF' > "$BACKUP_DIR/brew-restore.sh" | |
| #!/bin/bash | |
| echo "🔁 Restoring Homebrew environment..." | |
| echo "📥 Re-tapping repositories..." | |
| xargs brew tap < ~/brew-backup/tap-list.txt | |
| echo "📦 Installing formulae..." | |
| xargs brew install < ~/brew-backup/formula-list.txt | |
| echo "🧃 Installing casks..." | |
| xargs brew install --cask < ~/brew-backup/cask-list.txt | |
| echo "✅ Restoration complete." | |
| EOF | |
| chmod +x "$BACKUP_DIR/brew-restore.sh" | |
| echo "📝 To restore your Homebrew setup later, run:" | |
| echo "bash $BACKUP_DIR/brew-restore.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment