diff options
| author | sillylaird <sillyfanboy@gmail.com> | 2026-09-03 00:33:59 +0000 |
|---|---|---|
| committer | sillylaird <sillyfanboy@gmail.com> | 2026-09-03 00:33:59 +0000 |
| commit | 898b52edcb47bcb3e9d6106e74ca73e74ea01e70 (patch) | |
| tree | 85c6ee5ad58b860144551184d4cf86b560c62b91 /.agents/skills/skill-improver/scripts/backup-skill.sh | |
| download | www-898b52edcb47bcb3e9d6106e74ca73e74ea01e70.tar.gz www-898b52edcb47bcb3e9d6106e74ca73e74ea01e70.zip | |
Diffstat (limited to '')
| -rwxr-xr-x | .agents/skills/skill-improver/scripts/backup-skill.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/.agents/skills/skill-improver/scripts/backup-skill.sh b/.agents/skills/skill-improver/scripts/backup-skill.sh new file mode 100755 index 0000000..d4a5eee --- /dev/null +++ b/.agents/skills/skill-improver/scripts/backup-skill.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# backup-skill.sh - Backup skill files before applying updates +# Part of skill-improver + +# Usage: ./backup-skill.sh <skill-path> +# Example: ./backup-skill.sh ~/.claude/skills/git-workflow + +set -euo pipefail + +# Check if path provided +if [ $# -eq 0 ]; then + echo "Usage: $0 <skill-path>" + echo "Example: $0 ~/.claude/skills/git-workflow" + exit 1 +fi + +SKILL_PATH="$1" +SKILL_NAME=$(basename "$SKILL_PATH") +TIMESTAMP=$(date +%Y%m%d-%H%M%S) +BACKUP_DIR="$HOME/.claude/skills/backup/${SKILL_NAME}-${TIMESTAMP}" + +# Check if skill path exists +if [ ! -d "$SKILL_PATH" ]; then + echo "Error: Skill path not found: ${SKILL_PATH}" + exit 1 +fi + +# Create backup directory +echo "Creating backup directory: ${BACKUP_DIR}" +mkdir -p "$BACKUP_DIR" + +# Copy entire skill directory +echo "Backing up skill: ${SKILL_NAME}" +cp -R "$SKILL_PATH"/* "$BACKUP_DIR/" + +# Create backup manifest +cat > "$BACKUP_DIR/backup-manifest.txt" <<EOF +Backup Manifest +============== +Skill Name: ${SKILL_NAME} +Source Path: ${SKILL_PATH} +Backup Date: $(date) +Timestamp: ${TIMESTAMP} + +Files Backed Up: +$(find "$BACKUP_DIR" -type f ! -name "backup-manifest.txt" | sed "s|$BACKUP_DIR/||") + +Restore Instructions: +------------------- +To restore this backup, run: + cp -R ${BACKUP_DIR}/* ${SKILL_PATH}/ +EOF + +echo "Backup complete!" +echo "Backup location: ${BACKUP_DIR}" +echo "Files backed up: $(find "$BACKUP_DIR" -type f ! -name "backup-manifest.txt" | wc -l)" |
