- Add centralized configuration system with backup.env - Move configuration files to proper structure (config/ directory) - Remove hardcoded paths and make system portable - Fix security issue: remove password exposure in gen-conf.sh - Add comprehensive documentation (README.md, CLAUDE.md) - Create configuration template (backup.env.sample) - Add .gitignore to protect sensitive files - Update all scripts to use environment variables - Implement systemd template variable substitution 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
53 lines
1.3 KiB
Bash
53 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
# Script to initialize Restic repository for quantumrick backups
|
|
|
|
set -e
|
|
|
|
# Configuration should be sourced before running: source backup.env
|
|
|
|
REPO_PATH="$BACKUP_REPOSITORY"
|
|
CONFIG_FILE="$RESTIC_CONFIG_FILE"
|
|
|
|
echo "=== Initializing Restic Repository ==="
|
|
|
|
# Check if repository directory exists
|
|
if [ ! -d "$(dirname "$REPO_PATH")" ]; then
|
|
echo "Creating backup directory..."
|
|
sudo mkdir -p "$(dirname "$REPO_PATH")"
|
|
sudo chown $(whoami):$(whoami) "$(dirname "$REPO_PATH")"
|
|
fi
|
|
|
|
# Check if config file exists
|
|
if [ ! -f "$CONFIG_FILE" ]; then
|
|
echo "Error: Configuration file $CONFIG_FILE not found!"
|
|
echo "Please run generate-restic-config.sh first to create the configuration."
|
|
exit 1
|
|
fi
|
|
|
|
# Source the configuration
|
|
source "$CONFIG_FILE"
|
|
|
|
# Check if repository is already initialized
|
|
if restic -r "$REPO_PATH" cat config &>/dev/null; then
|
|
echo "Repository already initialized at $REPO_PATH"
|
|
exit 0
|
|
fi
|
|
|
|
echo "Initializing new Restic repository at $REPO_PATH"
|
|
|
|
# Initialize the repository
|
|
restic init -r "$REPO_PATH"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ Repository successfully initialized!"
|
|
echo "Repository path: $REPO_PATH"
|
|
echo "Configuration: $CONFIG_FILE"
|
|
else
|
|
echo "❌ Failed to initialize repository"
|
|
exit 1
|
|
fi
|
|
|
|
echo "=== Repository Information ==="
|
|
restic -r "$REPO_PATH" stats
|