Skip to content

Instantly share code, notes, and snippets.

@mayeenulislam
Last active June 5, 2026 06:16
Show Gist options
  • Select an option

  • Save mayeenulislam/5b96369c02893ea7befbc65aca1899cc to your computer and use it in GitHub Desktop.

Select an option

Save mayeenulislam/5b96369c02893ea7befbc65aca1899cc to your computer and use it in GitHub Desktop.
Custom script to backup Hermes Agent settings. A configurable script for smaller backup.
#!/bin/bash
# ==============================================================================
# DESCRIPTION:
# Custom script to back up Hermes Agent settings.
#
# FILE PLACEMENT (Linux):
# ~/hermes-backup.sh
#
# PERMISSIONS:
# chmod +x ~/hermes-backup.sh
#
# EXECUTION:
# ./hermes-backup.sh
#
# OUTPUT:
# Creates a timestamped backup file inside the directory: ~/hermes-backup/
#
# CONFIGURATION NOTE:
# Review the 'EXCLUDES' array inside the script before running.
# Add or remove patterns to prevent backing up large or temporary files
# (e.g., node_modules, logs, cache, virtual environments).
# ==============================================================================
# Configuration
SOURCE_DIR="$HOME/.hermes"
BACKUP_DIR="$HOME/hermes-backup"
TIMESTAMP=$(date +"%Y-%m-%d-%H%M%S")
FILENAME="hermes-backup-$TIMESTAMP.zip"
# Ensure backup directory exists
mkdir -p "$BACKUP_DIR"
# Exclusion patterns
EXCLUDES=(
".git/*"
"*/.git/*"
"cron/output/*"
"obsidian-hermes/*"
"node_modules/*"
"package-lock.json"
"npm-debug.log"
".npm/*"
"venv/*"
"venvs/*"
"__pycache__/*"
"*.pyc"
"*.pyo"
"*.pyd"
"logs/*"
"cache/*"
"*.log"
"*.lock"
"*.pid"
"*.db-shm"
"*.db-wal"
".DS_Store"
"images/*"
"audio_cache/*"
)
# Build exclusion string
EXCLUDE_ARGS=""
for pattern in "${EXCLUDES[@]}"; do
EXCLUDE_ARGS="$EXCLUDE_ARGS -x $pattern"
done
# Run zip
echo "Backing up $SOURCE_DIR to $BACKUP_DIR/$FILENAME..."
cd "$HOME" || exit
# Using -x relative to zip root, explicitly excluding folders and patterns
zip -r "$BACKUP_DIR/$FILENAME" .hermes -x "*/.git/*" "*/cron/output/*" "*/obsidian-hermes/*" "*/venv/*" "*/venvs/*" "*/node_modules/*" "*/logs/*" "*/audio_cache/*" "*/pastes/*" "*/sessions/*" "*/cache/*" $EXCLUDE_ARGS
echo "Backup completed: $BACKUP_DIR/$FILENAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment