citadel/backup/gen-conf.sh
Nicolas Duhamel 75a1e66ed2 Initial commit: Add quantumrick backup system
- Automated backup system using Restic
- Systemd timer integration for scheduled backups
- Service management tools (start/stop/restore)
- Multi-service support with template-based configuration
- Backup and restore functionality with test/production modes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-23 17:05:19 +02:00

55 lines
1.4 KiB
Bash

#!/bin/bash
# Script to generate Restic configuration with secure password
# Location: /home/citadel/services/paperless/generate-restic-config.sh
set -e
CONFIG_FILE="/home/citadel/backup/restic.conf"
REPO_PATH="/mnt/data/backup/quantumrick"
echo "=== Generating Restic Configuration ==="
# Check if config already exists
if [ -f "$CONFIG_FILE" ]; then
echo "Configuration file already exists at $CONFIG_FILE"
read -p "Do you want to overwrite it? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 1
fi
fi
# Generate secure password (32 characters)
echo "Generating secure password..."
RESTIC_PASSWORD=$(openssl rand -base64 32)
# Create configuration file
echo "Creating configuration file..."
cat > "$CONFIG_FILE" << EOF
# Restic configuration for Paperless NGX backups
# Generated on $(date)
# Repository path
export RESTIC_REPOSITORY="$REPO_PATH"
# Repository password
export RESTIC_PASSWORD="$RESTIC_PASSWORD"
# Cache directory (optional)
export RESTIC_CACHE_DIR="/tmp/restic-cache"
EOF
# Set secure permissions
chmod 600 "$CONFIG_FILE"
echo "✅ Configuration file created at $CONFIG_FILE"
echo "🔒 Password generated and saved securely"
echo ""
echo "⚠️ IMPORTANT: Save this password somewhere safe!"
echo " If you lose it, you won't be able to restore your backups!"
echo ""
echo "Password: $RESTIC_PASSWORD"
echo ""