| set -e | |
| # Logging function | |
| log() { | |
| echo "[$(date '+%Y-%m-%d %H:%M:%S')] [RESTIC] $*" | |
| } | |
| log "Starting restic installation..." | |
| # Update package lists and install dependencies | |
| log "Installing dependencies..." | |
| apt-get update | |
| apt-get install -y --no-install-recommends curl ca-certificates wget bzip2 jq | |
| # Download and install restic | |
| log "Downloading restic..." | |
| RESTIC_VERSION="0.18.0" | |
| RESTIC_URL="https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_linux_amd64.bz2" | |
| cd /tmp | |
| wget -O restic.bz2 "$RESTIC_URL" | |
| bunzip2 restic.bz2 | |
| chmod +x restic | |
| mv restic /usr/local/bin/ | |
| # Verify installation | |
| log "Verifying installation..." | |
| restic version | |
| # Create directories | |
| log "Creating directories..." | |
| mkdir -p /usr/local/share/restic /var/log/restic | |
| chown -R 1000:1000 /usr/local/share/restic /var/log/restic | |
| # Generate completion scripts | |
| restic generate --bash-completion /usr/local/share/restic/restic-completion.bash 2>/dev/null || true | |
| # Cleanup | |
| rm -rf /var/lib/apt/lists/* /tmp/restic* | |
| log "Restic installation completed successfully" |