Fix directories and restic installation
parent
dfb4bf0349
commit
3c87bbd882
76
manifest.jps
76
manifest.jps
|
@ -161,7 +161,7 @@ actions:
|
|||
configureAutoBackup:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands: bash "/home/jelastic/mb-backups/manage_backup_schedule.sh" add "0 0 * * *" "$(cat /etc/restic-password)"
|
||||
commands: bash "/home/litespeed/mb-backups/manage_backup_schedule.sh" add "0 0 * * *" "$(cat /etc/restic-password)"
|
||||
- return:
|
||||
type: info
|
||||
message: "Daily backup schedule configured successfully"
|
||||
|
@ -185,7 +185,7 @@ actions:
|
|||
checkBackupRepo:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands: bash /home/jelastic/mb-backups/check_backup_repo.sh
|
||||
commands: bash /home/litespeed/mb-backups/check_backup_repo.sh
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
@ -193,7 +193,7 @@ actions:
|
|||
backupnow:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands: bash /home/jelastic/mb-backups/backup_all.sh manual
|
||||
commands: bash /home/litespeed/mb-backups/backup_all.sh manual
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
@ -201,7 +201,7 @@ actions:
|
|||
backupcore:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands: bash /home/jelastic/mb-backups/backup_core_files.sh "$(cat /etc/restic-password)" "${settings.blabel}"
|
||||
commands: bash /home/litespeed/mb-backups/backup_core_files.sh "$(cat /etc/restic-password)" "${settings.blabel}"
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
@ -209,7 +209,7 @@ actions:
|
|||
backupmedia:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands: bash /home/jelastic/mb-backups/backup_media.sh "$(cat /etc/restic-password)" "${settings.blabel}"
|
||||
commands: bash /home/litespeed/mb-backups/backup_media.sh "$(cat /etc/restic-password)" "${settings.blabel}"
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
@ -217,7 +217,7 @@ actions:
|
|||
backupdb:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands: bash /home/jelastic/mb-backups/backup_database.sh "$(cat /etc/restic-password)" "${settings.blabel}"
|
||||
commands: bash /home/litespeed/mb-backups/backup_database.sh "$(cat /etc/restic-password)" "${settings.blabel}"
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
@ -225,7 +225,7 @@ actions:
|
|||
restore:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands: bash /home/jelastic/mb-backups/restore_backup_direct.sh "${settings.snapshotId}"
|
||||
commands: bash /home/litespeed/mb-backups/restore_backup_direct.sh "${settings.snapshotId}"
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
@ -233,7 +233,7 @@ actions:
|
|||
viewAllBackups:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands: bash /home/jelastic/mb-backups/view_snapshots.sh all
|
||||
commands: bash /home/litespeed/mb-backups/view_snapshots.sh all
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
@ -241,7 +241,7 @@ actions:
|
|||
viewCoreBackups:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands: bash /home/jelastic/mb-backups/view_snapshots.sh core_files
|
||||
commands: bash /home/litespeed/mb-backups/view_snapshots.sh core_files
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
@ -249,7 +249,7 @@ actions:
|
|||
viewMediaBackups:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands: bash /home/jelastic/mb-backups/view_snapshots.sh media_themes
|
||||
commands: bash /home/litespeed/mb-backups/view_snapshots.sh media_themes
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
@ -257,7 +257,7 @@ actions:
|
|||
viewDatabaseBackups:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands: bash /home/jelastic/mb-backups/view_snapshots.sh wordpress_db
|
||||
commands: bash /home/litespeed/mb-backups/view_snapshots.sh wordpress_db
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
@ -273,7 +273,7 @@ actions:
|
|||
checkRepoStats:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands: bash /home/jelastic/mb-backups/check_repo_stats.sh
|
||||
commands: bash /home/litespeed/mb-backups/check_repo_stats.sh
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
@ -307,37 +307,20 @@ actions:
|
|||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
# Download and install Restic
|
||||
- curl -L https://github.com/restic/restic/releases/download/v0.15.2/restic_0.15.2_linux_amd64.bz2 -o restic.bz2
|
||||
- bzip2 -d restic.bz2
|
||||
- chmod +x restic
|
||||
- mv restic /usr/local/bin/
|
||||
|
||||
# Create password file if it doesn't exist
|
||||
- if [ ! -f /etc/restic-password ]; then head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 > /etc/restic-password; fi
|
||||
|
||||
# Fix the core issue: Make password readable by everyone
|
||||
- chmod 644 /etc/restic-password
|
||||
|
||||
# Create backup and log directories
|
||||
- mkdir -p /mnt/backups
|
||||
- mkdir -p /home/jelastic/mb-backups/logs
|
||||
- chmod -R 755 /home/jelastic/mb-backups/logs
|
||||
- chmod 755 /mnt/backups
|
||||
|
||||
# Initialize the Restic repository
|
||||
- export RESTIC_PASSWORD=$(cat /etc/restic-password) && export RESTIC_REPOSITORY=/mnt/backups && restic init
|
||||
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/install-restic.sh
|
||||
- chmod +x install-restic.sh
|
||||
- bash install-restic.sh
|
||||
|
||||
importScripts:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- mkdir -p /home/jelastic/mb-backups
|
||||
- mkdir -p /home/jelastic/mb-backups/logs
|
||||
- mkdir -p /home/jelastic/mb-backups/logs/auto
|
||||
- mkdir -p /home/jelastic/mb-backups/logs/manual
|
||||
- mkdir -p /home/jelastic/mb-backups/logs/restore
|
||||
- cd /home/jelastic/mb-backups
|
||||
- mkdir -p /home/litespeed/mb-backups
|
||||
- mkdir -p /home/litespeed/mb-backups/logs
|
||||
- mkdir -p /home/litespeed/mb-backups/logs/auto
|
||||
- mkdir -p /home/litespeed/mb-backups/logs/manual
|
||||
- mkdir -p /home/litespeed/mb-backups/logs/restore
|
||||
- cd /home/litespeed/mb-backups
|
||||
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/backup_all.sh
|
||||
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/backup_core_files.sh
|
||||
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/backup_database.sh
|
||||
|
@ -348,7 +331,7 @@ actions:
|
|||
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/view_snapshots.sh
|
||||
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/check_backup_repo.sh
|
||||
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/check_repo_stats.sh
|
||||
- chmod +x /home/jelastic/mb-backups/*.sh
|
||||
- chmod +x /home/litespeed/mb-backups/*.sh
|
||||
|
||||
removeScripts:
|
||||
- cmd[cp]:
|
||||
|
@ -356,6 +339,17 @@ actions:
|
|||
commands:
|
||||
# Remove the crontab entry for the add-on
|
||||
- (crontab -l | grep -v "${globals.scriptPath}/manage_backup_schedule.sh" | crontab -) || true
|
||||
- rm -rf "${globals.scriptPath}" # Use globals.scriptPath
|
||||
# Stop any running backup processes
|
||||
- pkill -f "restic" || true
|
||||
- pkill -f "mb-backups" || true
|
||||
# Remove script directory
|
||||
- rm -rf "${globals.scriptPath}"
|
||||
# Remove backup repository completely
|
||||
- rm -rf /mnt/backups
|
||||
# Remove password file
|
||||
- rm -f /etc/restic-password
|
||||
- rm -f /etc/logrotate.d/backup-addon
|
||||
# Remove log rotation config
|
||||
- rm -f /etc/logrotate.d/backup-addon
|
||||
# Remove any restic cache
|
||||
- rm -rf /home/*/cache/restic || true
|
||||
- rm -rf /root/.cache/restic || true
|
|
@ -6,7 +6,7 @@ set -e
|
|||
# Configuration
|
||||
BACKUP_REPO_PATH="/mnt/backups"
|
||||
PASSWORD_FILE="/etc/restic-password"
|
||||
LOG_DIR="/home/jelastic/mb-backups/logs"
|
||||
LOG_DIR="/home/litespeed/mb-backups/logs"
|
||||
LOG_FILE="${LOG_DIR}/repo_stats_$(date +'%Y-%m-%d').log"
|
||||
RETENTION_POLICY="--keep-last 7 --prune" # Modify retention policy as needed
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Simple Restic Installation Script
|
||||
# Following Cloud Scripting best practices
|
||||
|
||||
set -e
|
||||
|
||||
echo "[INSTALL] Starting Restic installation..."
|
||||
|
||||
# Download and install Restic
|
||||
echo "[INSTALL] Downloading Restic..."
|
||||
curl -L https://github.com/restic/restic/releases/download/v0.15.2/restic_0.15.2_linux_amd64.bz2 -o restic.bz2
|
||||
bzip2 -d restic.bz2
|
||||
chmod +x restic
|
||||
mv restic /usr/local/bin/
|
||||
echo "[INSTALL] Restic installed successfully"
|
||||
|
||||
# Create password file
|
||||
echo "[INSTALL] Setting up password file..."
|
||||
if [ ! -f /etc/restic-password ]; then
|
||||
head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 > /etc/restic-password
|
||||
echo "[INSTALL] Password file created"
|
||||
fi
|
||||
chmod 644 /etc/restic-password
|
||||
|
||||
# Create directories
|
||||
echo "[INSTALL] Creating directories..."
|
||||
mkdir -p /mnt/backups
|
||||
mkdir -p /home/litespeed/mb-backups/logs
|
||||
chmod -R 755 /home/litespeed/mb-backups/logs
|
||||
chmod 755 /mnt/backups
|
||||
|
||||
# Initialize repository
|
||||
echo "[INSTALL] Initializing repository..."
|
||||
export RESTIC_PASSWORD=$(cat /etc/restic-password)
|
||||
export RESTIC_REPOSITORY=/mnt/backups
|
||||
|
||||
if restic snapshots >/dev/null 2>&1; then
|
||||
echo "[INSTALL] Repository already exists and is accessible"
|
||||
else
|
||||
echo "[INSTALL] Initializing new repository..."
|
||||
rm -rf /mnt/backups/* 2>/dev/null || true
|
||||
restic init
|
||||
echo "[INSTALL] Repository initialized successfully"
|
||||
fi
|
||||
|
||||
echo "[INSTALL] Installation completed successfully!"
|
Loading…
Reference in New Issue