Created
July 30, 2025 14:34
-
-
Save kenilt/a08cffdd0ae4d03117eee6ac7e997a04 to your computer and use it in GitHub Desktop.
Restore key dotfiles (.zshrc, .gitconfig, .vimrc, etc.), the ~/.config/ directory, and ~/.zsh and ~/.ssh folders
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 | |
# Set backup directory | |
BACKUP_DIR="$(pwd)/Backup" | |
SSH_BACKUP_DIR="$BACKUP_DIR/ssh" | |
CONFIG_BACKUP_DIR="$BACKUP_DIR/config" | |
ZSH_BACKUP_DIR="$BACKUP_DIR/zsh" | |
echo "π Starting restore..." | |
# Restore dotfiles | |
for file in "$BACKUP_DIR"/.*rc "$BACKUP_DIR"/.git*; do | |
if [ -f "$file" ]; then | |
cp "$file" ~/ | |
echo "β Restored $(basename "$file")" | |
fi | |
done | |
# Restore ~/.config | |
if [ -d "$CONFIG_BACKUP_DIR" ]; then | |
mkdir -p ~/.config | |
cp -r "$CONFIG_BACKUP_DIR"/* ~/.config/ | |
echo "β Restored ~/.config/" | |
fi | |
# Restore ~/.zsh | |
if [ -d "$ZSH_BACKUP_DIR" ]; then | |
mkdir -p ~/.zsh | |
cp -r "$ZSH_BACKUP_DIR"/* ~/.zsh/ | |
echo "β Restored ~/.zsh/" | |
fi | |
# Restore SSH config | |
if [ -d "$SSH_BACKUP_DIR" ]; then | |
mkdir -p ~/.ssh | |
cp -r "$SSH_BACKUP_DIR"/* ~/.ssh/ | |
chmod 700 ~/.ssh | |
chmod 600 ~/.ssh/id_* 2>/dev/null | |
chmod 644 ~/.ssh/config 2>/dev/null | |
echo "β Restored ~/.ssh/" | |
else | |
echo "β οΈ No SSH backup directory found." | |
fi | |
echo "β Restore complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment