File size: 1,092 Bytes
cf5db51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash

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"