Files
proclean-claw/backup_memory.sh
2026-04-09 22:22:54 +08:00

28 lines
880 B
Bash
Executable File

#!/bin/bash
# Memory Backup Script
# Purpose: Create a compressed archive of MEMORY.md and memory/ directory
WORKSPACE="/vol1/@apphome/trim.openclaw/data/workspace"
BACKUP_DIR="$WORKSPACE/backups"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BACKUP_NAME="memory_backup_$TIMESTAMP.tar.gz"
# Create backup directory if not exists
mkdir -p "$BACKUP_DIR"
echo "[$TIMESTAMP] Starting memory backup..."
# Create the archive
# We include MEMORY.md and the entire memory/ folder
tar -czf "$BACKUP_DIR/$BACKUP_NAME" -C "$WORKSPACE" MEMORY.md memory/
if [ $? -eq 0 ]; then
echo "[$TIMESTAMP] Backup successful: $BACKUP_DIR/$BACKUP_NAME"
# Keep only the last 7 days of backups to save space
find "$BACKUP_DIR" -name "memory_backup_*.tar.gz" -mtime +7 -exec rm {} \;
echo "[$TIMESTAMP] Cleaned up backups older than 7 days."
else
echo "[$TIMESTAMP] Backup FAILED!"
exit 1
fi