- 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>
52 lines
1.3 KiB
Bash
52 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
# Script to initialize Restic repository for Paperless NGX backups
|
|
# Location: /home/citadel/services/paperless/init-restic-repo.sh
|
|
|
|
set -e
|
|
|
|
REPO_PATH="/mnt/data/backup/quantumrick"
|
|
CONFIG_FILE="/home/citadel/backup/restic.conf"
|
|
|
|
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
|