The remote had one commit this branch did not (03f8a85), which adds the
Apache-2.0 LICENSE, the NOTICE and SPDX headers to every .py and .sh
file. The merge was clean - the headers sit at the top of each file and
my changes are further down.
The new files this branch added (languages.py, translations.py, the
cluster package, the new tests and scripts) were written after the
merge base, so the licence commit never saw them. They now carry the
same header, so the convention holds across the whole tree.
Nothing else changed. 883 tests passed / 8 failed - the same 8
pre-existing failures.
138 lines
3.8 KiB
Bash
Executable File
138 lines
3.8 KiB
Bash
Executable File
#!/bin/zsh
|
|
# Copyright 2026 Umbra Tools (umbratools.com)
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# backup_system.sh - Complete UmbraAudio system backup
|
|
|
|
set -e
|
|
|
|
SOURCE_ROOT="/Volumes/1TB_APL_Storage/UmbraAudio"
|
|
BACKUP_DIR="/tmp/backups"
|
|
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
|
|
|
# Parse arguments
|
|
MODE="full"
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--full) MODE="full"; shift ;;
|
|
--db) MODE="db"; shift ;;
|
|
--voices) MODE="voices"; shift ;;
|
|
--config) MODE="config"; shift ;;
|
|
--help|-h)
|
|
echo "Usage: $0 --full | --db | --voices | --config"
|
|
exit 0 ;;
|
|
*) echo "Unknown option: $1"; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
mkdir -p "$BACKUP_DIR"
|
|
|
|
echo "========================================="
|
|
echo "UmbraAudio System Backup"
|
|
echo "========================================="
|
|
echo "Mode: $MODE"
|
|
echo "Timestamp: $TIMESTAMP"
|
|
echo "========================================="
|
|
|
|
backup_db() {
|
|
local name="$1"
|
|
local src="$SOURCE_ROOT/.umbra/$name"
|
|
if [[ -f "$src" ]]; then
|
|
cp -a "$src" "$BACKUP_DIR/project_${name}.${TIMESTAMP}"
|
|
echo " ✓ $name"
|
|
else
|
|
echo " ⊘ $name (not found)"
|
|
fi
|
|
}
|
|
|
|
# Copy directory to backup with parent dir creation
|
|
backup_dir() {
|
|
local name="$1"
|
|
local rel_path="$name" # relative to SOURCE_ROOT
|
|
local src="$SOURCE_ROOT/$rel_path"
|
|
if [[ -d "$src" ]]; then
|
|
# Destination: flat name under BACKUP_DIR
|
|
local dst="$BACKUP_DIR/${name}_${TIMESTAMP}"
|
|
# Ensure parent directory exists
|
|
local dst_parent=$(dirname "$dst")
|
|
mkdir -p "$dst_parent"
|
|
cp -a "$src" "$dst"
|
|
echo " ✓ $name"
|
|
else
|
|
echo " ⊘ $name (not found)"
|
|
fi
|
|
}
|
|
|
|
case "$MODE" in
|
|
full)
|
|
echo "Backing up complete system..."
|
|
echo ""
|
|
echo "1. Project databases:"
|
|
backup_db "project.db"
|
|
backup_db "voice_registry.db"
|
|
backup_db "umbra.db"
|
|
echo ""
|
|
echo "2. Voice references:"
|
|
backup_dir "umbraaudio/voices"
|
|
echo ""
|
|
echo "3. Speaker configurations:"
|
|
if [[ -f "$SOURCE_ROOT/speakers.json" ]]; then
|
|
cp -a "$SOURCE_ROOT/speakers.json" "$BACKUP_DIR/speakers.${TIMESTAMP}"
|
|
echo " ✓ speakers.json"
|
|
fi
|
|
echo ""
|
|
echo "4. Configuration:"
|
|
if [[ -f "$SOURCE_ROOT/.env" ]]; then
|
|
cp -a "$SOURCE_ROOT/.env" "$BACKUP_DIR/.env.${TIMESTAMP}"
|
|
echo " ✓ .env"
|
|
fi
|
|
if [[ -f "$SOURCE_ROOT/umbraaudio/config.py" ]]; then
|
|
cp -a "$SOURCE_ROOT/umbraaudio/config.py" "$BACKUP_DIR/config.${TIMESTAMP}"
|
|
echo " ✓ config.py"
|
|
fi
|
|
echo ""
|
|
echo "5. Git state:"
|
|
cd "$SOURCE_ROOT" 2>/dev/null && git status --short > "$BACKUP_DIR/git_status.${TIMESTAMP}" 2>/dev/null && echo " ✓ git_status" || echo " ⊘ git (failed)"
|
|
echo ""
|
|
echo "6. Launchd services:"
|
|
launchctl list > "$BACKUP_DIR/launchd.${TIMESTAMP}" 2>/dev/null && echo " ✓ launchd" || echo " ⊘ launchd (failed)"
|
|
echo ""
|
|
echo "7. Audio generation state:"
|
|
if [[ -d "$SOURCE_ROOT/generation" ]]; then
|
|
backup_dir "generation"
|
|
fi
|
|
echo ""
|
|
echo "========================================="
|
|
echo "✅ Full backup complete!"
|
|
echo "Files saved to: $BACKUP_DIR/"
|
|
echo "========================================="
|
|
;;
|
|
|
|
db)
|
|
echo "Backing up databases only..."
|
|
backup_db "project.db"
|
|
backup_db "voice_registry.db"
|
|
backup_db "umbra.db"
|
|
;;
|
|
|
|
voices)
|
|
echo "Backing up voice references..."
|
|
backup_dir "umbraaudio/voices"
|
|
if [[ -f "$SOURCE_ROOT/speakers.json" ]]; then
|
|
cp -a "$SOURCE_ROOT/speakers.json" "$BACKUP_DIR/speakers.${TIMESTAMP}"
|
|
fi
|
|
;;
|
|
|
|
config)
|
|
echo "Backing up configuration only..."
|
|
if [[ -f "$SOURCE_ROOT/.env" ]]; then
|
|
cp -a "$SOURCE_ROOT/.env" "$BACKUP_DIR/.env.${TIMESTAMP}"
|
|
echo " ✓ .env"
|
|
fi
|
|
if [[ -f "$SOURCE_ROOT/umbraaudio/config.py" ]]; then
|
|
cp -a "$SOURCE_ROOT/umbraaudio/config.py" "$BACKUP_DIR/config.${TIMESTAMP}"
|
|
echo " ✓ config.py"
|
|
fi
|
|
;;
|
|
esac
|