Skip to content
Back to skills

Collection

DSecurity

Backup dotfiles before changes and restore if needed

  • 24 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 8, 2026
code-qualityshellbashrefactoringgit

Security analysis

D50/100
  • criticalModifies startup scripts or system services for persistence
  • criticalModifies startup scripts or system services for persistence

Pro scans all 21 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add mattnigh/skills_collection --skill collection --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Collection?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Collection
[![Security: D — Skills Directory](https://www.skillsdirectory.com/api/skills/mattnigh-collection-54e73987/badge)](https://www.skillsdirectory.com/skills/mattnigh-collection-54e73987)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: backup-and-restore
description: Backup dotfiles before changes and restore if needed
---

# Backup and Restore Dotfiles

This skill manages backups of dotfiles configurations before making changes.

## Task - Backup

When creating a backup, you should:

1. Create a backup directory with timestamp:
   ```bash
   ~/.dotfiles-backups/backup-YYYY-MM-DD-HHMMSS/
   ```

2. Copy current state of:
   - All `*.ln` files in ~/.dotfiles
   - Current neovim config (`~/.config/nvim`)
   - Current tmux config (`~/.tmux.conf`)
   - Current bash config (`~/.bashrc`, `~/.bash_profile`)
   - TPM plugins directory (`~/.tmux/plugins/`)
   - Lazy.nvim plugins directory (`~/.local/share/nvim/`)

3. Create a backup manifest file listing:
   - Timestamp
   - Git commit hash (if in git repo)
   - List of backed up files
   - Reason for backup

4. Compress old backups (older than 30 days)

## Task - Restore

When restoring from a backup, you should:

1. List available backups with timestamps

2. Ask user which backup to restore

3. Show what will be restored (diff if possible)

4. Confirm before restoring

5. Restore files:
   - Copy backed up files to original locations
   - Re-run `rake install` for symlinks
   - Restore plugin directories

6. Verify restoration:
   - Check symlinks are correct
   - Test neovim loads without errors
   - Test tmux starts correctly

7. Offer to restore previous state if issues occur

## Backup Script

Location: `~/.dotfiles/.claude/skills/backup-and-restore/backup.sh`

```bash
#!/bin/bash
BACKUP_DIR="$HOME/.dotfiles-backups/backup-$(date +%Y-%m-%d-%H%M%S)"
mkdir -p "$BACKUP_DIR"

# Backup dotfiles source
cp -r ~/.dotfiles "$BACKUP_DIR/dotfiles"

# Backup actual configs
cp -r ~/.config/nvim "$BACKUP_DIR/nvim" 2>/dev/null || true
cp ~/.tmux.conf "$BACKUP_DIR/tmux.conf" 2>/dev/null || true
cp ~/.bashrc "$BACKUP_DIR/bashrc" 2>/dev/null || true
cp ~/.bash_profile "$BACKUP_DIR/bash_profile" 2>/dev/null || true

# Backup plugins
cp -r ~/.tmux/plugins "$BACKUP_DIR/tmux-plugins" 2>/dev/null || true
cp -r ~/.local/share/nvim "$BACKUP_DIR/nvim-data" 2>/dev/null || true

# Create manifest
cat > "$BACKUP_DIR/manifest.txt" <<EOF
Backup created: $(date)
Git commit: $(cd ~/.dotfiles && git rev-parse HEAD 2>/dev/null || echo "not in git")
Reason: ${1:-"Manual backup"}
Files backed up:
$(find "$BACKUP_DIR" -type f | sort)
EOF

echo "Backup created: $BACKUP_DIR"
```

## Restore Script

Location: `~/.dotfiles/.claude/skills/backup-and-restore/restore.sh`

```bash
#!/bin/bash
if [ -z "$1" ]; then
  echo "Usage: $0 <backup-directory>"
  echo "Available backups:"
  ls -1 ~/.dotfiles-backups/
  exit 1
fi

BACKUP_DIR="$HOME/.dotfiles-backups/$1"
if [ ! -d "$BACKUP_DIR" ]; then
  echo "Backup not found: $BACKUP_DIR"
  exit 1
fi

echo "Restoring from: $BACKUP_DIR"
cat "$BACKUP_DIR/manifest.txt"
echo ""
read -p "Continue with restore? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
  exit 1
fi

# Restore files
cp -r "$BACKUP_DIR/dotfiles" ~/.dotfiles
cp -r "$BACKUP_DIR/nvim" ~/.config/nvim 2>/dev/null || true
cp "$BACKUP_DIR/tmux.conf" ~/.tmux.conf 2>/dev/null || true
cp "$BACKUP_DIR/bashrc" ~/.bashrc 2>/dev/null || true
cp "$BACKUP_DIR/bash_profile" ~/.bash_profile 2>/dev/null || true

echo "Restore complete. Run 'rake install' to update symlinks."
```

## When to Use

**Backup before**:
- Major plugin updates
- Configuration refactoring
- Installing new tools
- Following update-dotfiles-trends suggestions
- Experimenting with new configs

**Restore when**:
- Neovim won't start
- Tmux has errors
- Shell configuration broken
- Plugin conflicts
- Need to rollback changes

## Output

For backup operations:
- Backup location
- Size of backup
- Files included
- Git commit reference

For restore operations:
- Available backups with dates
- Backup manifest
- Diff of changes (if possible)
- Restoration status
- Next steps (reload shell, restart tmux, etc.)

Files in this skill

  • 0Chan-smc__claude-code-workflow-lab__claude__skills__frontend-dev-guidelines__SKILL.md15.1 KB
  • 17hz__nextjs-template__claude__skills__example-skill__SKILL.md316 B
  • 1ambda__dataops-platform__claude__skills__context-synthesis__SKILL.md3.5 KB
  • 1natsu172__dotfiles__claude__skills__git-analysis__SKILL.md5.4 KB
  • 1natsu172__dotfiles__claude__skills__github-pr-best-practices__SKILL.md7.7 KB
  • 23Maestro__prospect-pipeline__claude__skills__npid-fastapi-skill.md26.1 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-code-javascript__SKILL.md15.7 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-code-python__SKILL.md17.5 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-expression-syntax__SKILL.md9.4 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-mcp-tools-expert__SKILL.md12.5 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-node-configuration__SKILL.md16.6 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-workflow-patterns__SKILL.md11.2 KB
  • 3x-Projetos__claude-memory-framework__claude__skills__scientist__SKILL.md14.8 KB
  • 5MinFutures__futures-arena__claude__skills__migration-tracker__SKILL.md16.2 KB
  • 5MinFutures__futures-arena__claude__skills__planning-guidelines__SKILL.md11.8 KB
  • 92Bilal26__TaskPilotAI__claude__skills__assessment-builder__SKILL.md17.5 KB
  • 92Bilal26__TaskPilotAI__claude__skills__book-scaffolding__SKILL.md19.1 KB
  • 92Bilal26__TaskPilotAI__claude__skills__code-validation-sandbox__SKILL.md6.2 KB
  • 92Bilal26__TaskPilotAI__claude__skills__exercise-designer__SKILL.md18.1 KB
  • 92Bilal26__TaskPilotAI__claude__skills__learning-objectives__SKILL.md24.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…