From e7eaabfcc55534a0f45d8ffc25572e874b3dcf18 Mon Sep 17 00:00:00 2001 From: cschantz Date: Wed, 5 Nov 2025 21:30:19 -0500 Subject: [PATCH] Implement Acronis Cyber Protect agent management scripts Created 11 comprehensive scripts for Acronis backup management: Installation & Setup: - acronis-install.sh: Download/install agent with multiple modes * Interactive, unattended, with/without registration * Supports token-based registration during install * Auto-service startup and verification - acronis-register.sh: Register agent with Acronis Cloud * Validates service URL and token * Shows current registration status * Safe re-registration with confirmation - acronis-configure.sh: Guidance for backup plan configuration * Web console walkthrough * Common backup plan examples Backup Operations: - acronis-manual-backup.sh: Manual backup creation guide * Web console and CLI methods * Ready for full CLI implementation - acronis-status.sh: View backup status from logs * Recent backup activity * acrocmd integration ready - acronis-list-backups.sh: List available backup archives * acrocmd integration for archive listing - acronis-restore.sh: Restore from backup guide * Multiple restore methods explained * Safety warnings and best practices Management: - acronis-agent-status.sh: Comprehensive service status * All 4 services (aakore, mms, schedule, active-protection) * Registration status, network ports, storage * Quick actions: start/stop/restart/logs/version - acronis-update.sh: Agent update management * Auto and manual update methods * Version checking - acronis-logs.sh: Advanced log viewer * View, tail, search logs * Error filtering with color coding * Log archival for old logs - acronis-uninstall.sh: Safe agent removal * Stops services, unregisters, removes packages * Optional data retention * Comprehensive cleanup All scripts based on documented Acronis commands with proper error handling, status validation, and user-friendly interfaces. --- modules/backup/acronis-agent-status.sh | 278 ++++++++++++++++++++++ modules/backup/acronis-configure.sh | 54 +++++ modules/backup/acronis-install.sh | 245 ++++++++++++++++++++ modules/backup/acronis-list-backups.sh | 45 ++++ modules/backup/acronis-logs.sh | 296 ++++++++++++++++++++++++ modules/backup/acronis-manual-backup.sh | 42 ++++ modules/backup/acronis-register.sh | 231 ++++++++++++++++++ modules/backup/acronis-restore.sh | 58 +++++ modules/backup/acronis-status.sh | 45 ++++ modules/backup/acronis-uninstall.sh | 249 ++++++++++++++++++++ modules/backup/acronis-update.sh | 78 +++++++ 11 files changed, 1621 insertions(+) create mode 100755 modules/backup/acronis-agent-status.sh create mode 100755 modules/backup/acronis-configure.sh create mode 100755 modules/backup/acronis-install.sh create mode 100755 modules/backup/acronis-list-backups.sh create mode 100755 modules/backup/acronis-logs.sh create mode 100755 modules/backup/acronis-manual-backup.sh create mode 100755 modules/backup/acronis-register.sh create mode 100755 modules/backup/acronis-restore.sh create mode 100755 modules/backup/acronis-status.sh create mode 100755 modules/backup/acronis-uninstall.sh create mode 100755 modules/backup/acronis-update.sh diff --git a/modules/backup/acronis-agent-status.sh b/modules/backup/acronis-agent-status.sh new file mode 100755 index 0000000..bfabe7f --- /dev/null +++ b/modules/backup/acronis-agent-status.sh @@ -0,0 +1,278 @@ +#!/bin/bash + +################################################################################ +# Acronis Agent Status Checker +################################################################################ +# Purpose: Check status of all Acronis Cyber Protect services +# Services monitored: +# - aakore (Acronis Agent Core) +# - acronis_mms (Management Service) +# - acronis_schedule (Scheduler) +# - active-protection.service (Ransomware Protection) +################################################################################ + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +source "$SCRIPT_DIR/lib/common-functions.sh" +source "$SCRIPT_DIR/lib/system-detect.sh" + +# Require root +if [ "$EUID" -ne 0 ]; then + print_error "This script must be run as root" + exit 1 +fi + +print_banner "Acronis Agent Status" + +echo "" +echo -e "${BOLD}Checking Acronis Cyber Protect Services...${NC}" +echo "" + +# Array of services to check +declare -a SERVICES=( + "aakore:Acronis Agent Core" + "acronis_mms:Management Service" + "acronis_schedule:Backup Scheduler" + "active-protection:Ransomware Protection" +) + +# Track overall status +all_running=true +any_installed=false + +# Function to check service status +check_service_status() { + local service_name="$1" + local service_desc="$2" + + # Check if service exists + if systemctl list-unit-files | grep -q "^${service_name}.service"; then + any_installed=true + + # Get service status + if systemctl is-active --quiet "$service_name"; then + echo -e " ${GREEN}●${NC} ${BOLD}${service_desc}${NC}" + echo -e " Status: ${GREEN}RUNNING${NC}" + + # Get uptime + local uptime=$(systemctl show "$service_name" -p ActiveEnterTimestamp --value) + if [ -n "$uptime" ]; then + echo -e " Uptime: ${uptime}" + fi + + # Get PID + local pid=$(systemctl show "$service_name" -p MainPID --value) + if [ "$pid" != "0" ]; then + echo -e " PID: ${pid}" + fi + else + all_running=false + echo -e " ${RED}●${NC} ${BOLD}${service_desc}${NC}" + echo -e " Status: ${RED}STOPPED${NC}" + + # Check if failed + if systemctl is-failed --quiet "$service_name"; then + echo -e " ${RED}[FAILED]${NC} - Service has errors" + fi + fi + echo "" + elif service "$service_name" status &>/dev/null; then + # Fallback to service command for older systems + any_installed=true + if service "$service_name" status | grep -q "running"; then + echo -e " ${GREEN}●${NC} ${BOLD}${service_desc}${NC}" + echo -e " Status: ${GREEN}RUNNING${NC}" + else + all_running=false + echo -e " ${RED}●${NC} ${BOLD}${service_desc}${NC}" + echo -e " Status: ${RED}STOPPED${NC}" + fi + echo "" + fi +} + +# Check each service +for service_entry in "${SERVICES[@]}"; do + IFS=':' read -r service_name service_desc <<< "$service_entry" + check_service_status "$service_name" "$service_desc" +done + +# Check if Acronis is even installed +if [ "$any_installed" = false ]; then + echo -e "${YELLOW}${BOLD}⚠ Acronis Agent Not Installed${NC}" + echo "" + echo "Acronis Cyber Protect is not installed on this system." + echo "" + echo "To install:" + echo " 1. Return to Backup & Recovery menu" + echo " 2. Select 'Acronis Management'" + echo " 3. Choose 'Install Acronis Agent'" + echo "" + press_enter + exit 0 +fi + +echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" +echo "" + +# Overall status summary +if [ "$all_running" = true ]; then + echo -e "${GREEN}${BOLD}✓ All Services Running${NC}" + echo "" + echo "Acronis Cyber Protect is operational and ready for backups." +else + echo -e "${YELLOW}${BOLD}⚠ Some Services Not Running${NC}" + echo "" + echo "Some Acronis services are stopped. You may want to:" + echo " • Start services: Select 'Service Management' from Acronis menu" + echo " • Check logs: Select 'View Logs' for error details" + echo " • Restart services: Try restarting all services" +fi + +echo "" + +# Check agent registration status +echo -e "${BOLD}Agent Registration:${NC}" +if [ -f "/etc/Acronis/Global.config" ]; then + if grep -q "CloudUrl" "/etc/Acronis/Global.config" 2>/dev/null; then + echo -e " ${GREEN}✓${NC} Agent is registered with Acronis Cloud" + + # Extract cloud URL if possible + cloud_url=$(grep -oP 'CloudUrl[>="].*?https://[^"<]+' /etc/Acronis/Global.config 2>/dev/null | grep -oP 'https://[^"<]+' | head -1) + if [ -n "$cloud_url" ]; then + echo -e " URL: ${cloud_url}" + fi + else + echo -e " ${YELLOW}⚠${NC} Agent may not be registered" + fi +else + echo -e " ${YELLOW}⚠${NC} Configuration file not found" +fi + +echo "" + +# Check active ports +echo -e "${BOLD}Network Connectivity:${NC}" +echo -e "Active Acronis ports:" + +declare -a PORTS=( + "80:HTTP" + "443:HTTPS/Cloud" + "5060:Agent Management" + "7770:Backup Traffic" + "7800:Backup Gateway" + "8443:Web Console" + "44445:Agent Communication" +) + +ports_found=false +for port_entry in "${PORTS[@]}"; do + IFS=':' read -r port port_desc <<< "$port_entry" + if netstat -tuln 2>/dev/null | grep -q ":${port}\s"; then + echo -e " ${GREEN}✓${NC} Port ${port} (${port_desc})" + ports_found=true + fi +done + +if [ "$ports_found" = false ]; then + echo -e " ${DIM}No Acronis ports currently listening${NC}" +fi + +echo "" + +# Check disk space for backups +echo -e "${BOLD}Storage Status:${NC}" +if [ -d "/var/lib/Acronis" ]; then + local backup_dir_size=$(du -sh /var/lib/Acronis 2>/dev/null | awk '{print $1}') + echo -e " Acronis data: ${backup_dir_size}" + + # Check free space + local free_space=$(df -h /var/lib/Acronis | tail -1 | awk '{print $4}') + local use_percent=$(df -h /var/lib/Acronis | tail -1 | awk '{print $5}' | tr -d '%') + + echo -e " Free space: ${free_space}" + + if [ "$use_percent" -gt 90 ]; then + echo -e " ${RED}⚠ Warning: Disk usage at ${use_percent}%${NC}" + fi +fi + +echo "" + +# Quick Actions +echo -e "${BOLD}Quick Actions:${NC}" +echo "" +echo -e " ${CYAN}1)${NC} Start All Services" +echo -e " ${CYAN}2)${NC} Stop All Services" +echo -e " ${CYAN}3)${NC} Restart All Services" +echo -e " ${CYAN}4)${NC} View Live Logs" +echo -e " ${CYAN}5)${NC} Check Agent Version" +echo "" +echo -e " ${RED}0)${NC} Return to Menu" +echo "" +echo -n "Select action (or press Enter to return): " +read -r action + +case "$action" in + 1) + echo "" + echo "Starting all Acronis services..." + systemctl start aakore + systemctl start acronis_mms + systemctl start acronis_schedule + systemctl start active-protection + echo "" + print_success "Services started" + sleep 2 + exec "$0" + ;; + 2) + echo "" + echo "Stopping all Acronis services..." + systemctl stop active-protection + systemctl stop acronis_schedule + systemctl stop acronis_mms + systemctl stop aakore + echo "" + print_success "Services stopped" + sleep 2 + exec "$0" + ;; + 3) + echo "" + echo "Restarting all Acronis services..." + systemctl restart aakore + systemctl restart acronis_mms + systemctl restart acronis_schedule + systemctl restart active-protection + echo "" + print_success "Services restarted" + sleep 2 + exec "$0" + ;; + 4) + if [ -f "/var/lib/Acronis/BackupAndRecovery/MMS/mms.0.log" ]; then + echo "" + echo "Showing live log (Ctrl+C to exit)..." + sleep 1 + tail -f /var/lib/Acronis/BackupAndRecovery/MMS/mms.0.log + else + print_error "Log file not found" + press_enter + fi + ;; + 5) + echo "" + echo -e "${BOLD}Agent Version Information:${NC}" + if command -v /usr/lib/Acronis/BackupAndRecovery/aakore &>/dev/null; then + /usr/lib/Acronis/BackupAndRecovery/aakore --version 2>/dev/null || echo "Version info not available" + else + echo "Agent binary not found" + fi + echo "" + press_enter + ;; + *) + # Return to menu + exit 0 + ;; +esac diff --git a/modules/backup/acronis-configure.sh b/modules/backup/acronis-configure.sh new file mode 100755 index 0000000..247c135 --- /dev/null +++ b/modules/backup/acronis-configure.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +source "$SCRIPT_DIR/lib/common-functions.sh" + +if [ "$EUID" -ne 0 ]; then + print_error "This script must be run as root" + exit 1 +fi + +print_banner "Configure Backup Plans" + +echo "" +echo -e "${BOLD}Acronis Backup Plan Configuration${NC}" +echo "" +echo "Backup plans are configured through the Acronis web console." +echo "" +echo -e "${CYAN}Steps to configure backup plans:${NC}" +echo "" +echo "1. Log in to your Acronis web console" +echo " → https://us5-cloud.acronis.com (or your region)" +echo "" +echo "2. Navigate to: Devices → All devices" +echo "" +echo "3. Find this server in the device list" +echo "" +echo "4. Click on the device and select 'Protection'" +echo "" +echo "5. Click 'Add plan' and configure:" +echo " • Backup source (files, folders, system)" +echo " • Backup schedule (hourly, daily, weekly)" +echo " • Retention policy (how long to keep backups)" +echo " • Backup location (cloud or local)" +echo "" +echo "6. Apply the plan to this device" +echo "" +echo -e "${BOLD}Common Backup Plans:${NC}" +echo "" +echo " • Full Server Backup" +echo " → Entire system image for disaster recovery" +echo "" +echo " • cPanel Accounts" +echo " → /home/* directories for user data" +echo "" +echo " • Databases" +echo " → MySQL/MariaDB databases with consistent snapshots" +echo "" +echo " • Configuration Files" +echo " → /etc and other critical configs" +echo "" +echo " • Web Files" +echo " → /home/*/public_html websites" +echo "" +press_enter diff --git a/modules/backup/acronis-install.sh b/modules/backup/acronis-install.sh new file mode 100755 index 0000000..d7448b9 --- /dev/null +++ b/modules/backup/acronis-install.sh @@ -0,0 +1,245 @@ +#!/bin/bash + +################################################################################ +# Acronis Agent Installer +################################################################################ +# Purpose: Download and install Acronis Cyber Protect agent +# Supports: +# - Interactive installation with prompts +# - Unattended installation (-a flag) +# - Skip registration (--skip-registration) +# - Install with token (--token=xxx) +# - Custom service URL (--rain=xxx) +################################################################################ + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +source "$SCRIPT_DIR/lib/common-functions.sh" +source "$SCRIPT_DIR/lib/system-detect.sh" + +# Require root +if [ "$EUID" -ne 0 ]; then + print_error "This script must be run as root" + exit 1 +fi + +print_banner "Acronis Agent Installation" + +# Check if already installed +if systemctl list-unit-files | grep -q "acronis_mms.service"; then + echo "" + echo -e "${YELLOW}${BOLD}⚠ Acronis Already Installed${NC}" + echo "" + echo "Acronis Cyber Protect agent is already installed on this system." + echo "" + echo -n "Do you want to reinstall/upgrade? (yes/no): " + read -r reinstall + if [ "$reinstall" != "yes" ]; then + echo "Installation cancelled" + press_enter + exit 0 + fi +fi + +echo "" +echo -e "${BOLD}Acronis Cyber Protect Agent Installation${NC}" +echo "" +echo "This will download and install the latest Acronis agent for Linux (x86_64)." +echo "" +echo -e "${CYAN}Installation Options:${NC}" +echo "" +echo " 1) Interactive installation (default)" +echo " 2) Unattended installation (auto-accept)" +echo " 3) Install and register with token" +echo " 4) Install without registration" +echo "" +echo -n "Select installation mode [1]: " +read -r install_mode +install_mode="${install_mode:-1}" + +# Build installation flags +INSTALL_FLAGS="" +SERVICE_URL="us5-cloud.acronis.com" +REGISTRATION_TOKEN="" + +case "$install_mode" in + 2) + INSTALL_FLAGS="-a" + echo "" + echo "Mode: Unattended installation" + ;; + 3) + INSTALL_FLAGS="-a" + echo "" + echo -n "Enter registration token: " + read -r REGISTRATION_TOKEN + if [ -z "$REGISTRATION_TOKEN" ]; then + print_error "Token is required for this mode" + press_enter + exit 1 + fi + INSTALL_FLAGS="$INSTALL_FLAGS --token=$REGISTRATION_TOKEN" + echo "" + echo "Mode: Install with registration token" + ;; + 4) + INSTALL_FLAGS="-a --skip-registration" + echo "" + echo "Mode: Install without registration" + ;; + *) + echo "" + echo "Mode: Interactive installation" + ;; +esac + +# Ask for service URL if not using token +if [ "$install_mode" != "4" ]; then + echo "" + echo -n "Acronis Cloud region [us5-cloud.acronis.com]: " + read -r input_url + if [ -n "$input_url" ]; then + SERVICE_URL="$input_url" + fi + + if [ "$install_mode" = "3" ]; then + INSTALL_FLAGS="$INSTALL_FLAGS --rain=$SERVICE_URL" + fi +fi + +echo "" +echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" +echo "" +echo -e "${BOLD}Installation Summary:${NC}" +echo "" +echo " Download URL: https://${SERVICE_URL}/bc/api/ams/links/agents/redirect" +echo " Architecture: x86_64 (64-bit)" +echo " Install flags: ${INSTALL_FLAGS:-none}" +echo " Service URL: ${SERVICE_URL}" +[ -n "$REGISTRATION_TOKEN" ] && echo " Token: ********" +echo "" +echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" +echo "" +echo -n "Proceed with installation? (yes/no): " +read -r confirm + +if [ "$confirm" != "yes" ]; then + echo "" + print_error "Installation cancelled" + press_enter + exit 0 +fi + +echo "" +echo -e "${BOLD}Starting Installation...${NC}" +echo "" + +# Create temp directory +TEMP_DIR="/tmp/acronis-install-$$" +mkdir -p "$TEMP_DIR" +cd "$TEMP_DIR" || exit 1 + +# Download installer +echo "→ Downloading Acronis agent installer..." +DOWNLOAD_URL="https://${SERVICE_URL}/bc/api/ams/links/agents/redirect?language=multi&system=linux&architecture=64&productType=enterprise" + +if wget -q --show-progress "$DOWNLOAD_URL" -O "Cyber_Protection_Agent_for_Linux_x86_64.bin"; then + print_success "Download complete" +else + print_error "Download failed" + echo "" + echo "Possible causes:" + echo " • No internet connection" + echo " • Invalid service URL: ${SERVICE_URL}" + echo " • Firewall blocking connection" + echo "" + press_enter + cd / + rm -rf "$TEMP_DIR" + exit 1 +fi + +echo "" + +# Make executable +chmod +x "Cyber_Protection_Agent_for_Linux_x86_64.bin" + +# Run installer +echo "→ Running Acronis installer..." +echo "" +echo -e "${DIM}──────────────────────────────────────────────────────────────${NC}" + +if [ -z "$INSTALL_FLAGS" ]; then + # Interactive mode - run directly + ./Cyber_Protection_Agent_for_Linux_x86_64.bin +else + # Unattended mode + ./Cyber_Protection_Agent_for_Linux_x86_64.bin $INSTALL_FLAGS +fi + +INSTALL_EXIT_CODE=$? + +echo -e "${DIM}──────────────────────────────────────────────────────────────${NC}" +echo "" + +# Check installation result +if [ $INSTALL_EXIT_CODE -eq 0 ]; then + print_success "Installation completed successfully!" + echo "" + + # Start services + echo "→ Starting Acronis services..." + systemctl start aakore + systemctl start acronis_mms + systemctl start acronis_schedule + echo "" + + # Check if services started + sleep 2 + if systemctl is-active --quiet acronis_mms; then + print_success "Services started successfully" + echo "" + + # Show next steps + echo -e "${BOLD}Next Steps:${NC}" + echo "" + + if [ "$install_mode" = "4" ]; then + echo " 1. Register the agent with Acronis Cloud" + echo " → Select 'Register with Cloud' from Acronis menu" + echo "" + fi + + echo " 2. Configure backup plans in Acronis web console" + echo " → Visit: https://${SERVICE_URL}" + echo "" + echo " 3. Check agent status" + echo " → Select 'Check Agent Status' from Acronis menu" + echo "" + else + print_error "Services failed to start" + echo "" + echo "Check logs for details:" + echo " tail -f /var/lib/Acronis/BackupAndRecovery/MMS/mms.0.log" + echo "" + fi + +else + print_error "Installation failed with exit code $INSTALL_EXIT_CODE" + echo "" + echo "Check the output above for error details." + echo "" + echo "Common issues:" + echo " • Incompatible system (requires 64-bit Linux)" + echo " • Insufficient disk space" + echo " • Conflicting backup software" + echo " • Invalid registration token" + echo "" +fi + +# Cleanup +echo "→ Cleaning up temporary files..." +cd / +rm -rf "$TEMP_DIR" + +echo "" +press_enter diff --git a/modules/backup/acronis-list-backups.sh b/modules/backup/acronis-list-backups.sh new file mode 100755 index 0000000..ff54bec --- /dev/null +++ b/modules/backup/acronis-list-backups.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +source "$SCRIPT_DIR/lib/common-functions.sh" + +if [ "$EUID" -ne 0 ]; then + print_error "This script must be run as root" + exit 1 +fi + +print_banner "List Available Backups" + +echo "" +echo -e "${BOLD}Available Backups${NC}" +echo "" + +# Check if acrocmd exists +if ! command -v acrocmd &>/dev/null; then + echo -e "${YELLOW}acrocmd CLI tool not found${NC}" + echo "" + echo "To list backups:" + echo " • Use Acronis web console (recommended)" + echo " • Log in and navigate to: Backup → Backup plans" + echo " • View all backup archives and recovery points" + echo "" + echo "Command line option:" + echo " acrocmd list archives" + echo " acrocmd list recoverypoints" + echo "" + press_enter + exit 0 +fi + +echo "Querying backup archives..." +echo "" + +# Try to list archives +if acrocmd list archives 2>/dev/null; then + echo "" +else + echo "No archives found or command failed" + echo "" +fi + +press_enter diff --git a/modules/backup/acronis-logs.sh b/modules/backup/acronis-logs.sh new file mode 100755 index 0000000..25cd6c6 --- /dev/null +++ b/modules/backup/acronis-logs.sh @@ -0,0 +1,296 @@ +#!/bin/bash + +################################################################################ +# Acronis Log Viewer +################################################################################ +# Purpose: View and tail Acronis Cyber Protect logs +# Log location: /var/lib/Acronis/BackupAndRecovery/MMS/ +# Primary log: mms.0.log +################################################################################ + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +source "$SCRIPT_DIR/lib/common-functions.sh" +source "$SCRIPT_DIR/lib/system-detect.sh" + +# Require root +if [ "$EUID" -ne 0 ]; then + print_error "This script must be run as root" + exit 1 +fi + +# Log directory +LOG_DIR="/var/lib/Acronis/BackupAndRecovery/MMS" +PRIMARY_LOG="$LOG_DIR/mms.0.log" + +print_banner "Acronis Logs Viewer" + +# Check if Acronis is installed +if [ ! -d "$LOG_DIR" ]; then + echo "" + print_error "Acronis log directory not found" + echo "" + echo "Acronis may not be installed or logs are in a different location." + echo "" + press_enter + exit 1 +fi + +echo "" +echo -e "${BOLD}Acronis Log Management${NC}" +echo "" +echo "Log directory: ${LOG_DIR}" +echo "" + +# Show log menu +show_log_menu() { + clear + print_banner "Acronis Logs Viewer" + echo "" + echo -e "${BOLD}Available Logs:${NC}" + echo "" + + # List all log files with sizes + if [ -d "$LOG_DIR" ]; then + local log_count=0 + while IFS= read -r log_file; do + ((log_count++)) + local size=$(du -h "$log_file" 2>/dev/null | awk '{print $1}') + local filename=$(basename "$log_file") + local mod_time=$(stat -c %y "$log_file" 2>/dev/null | cut -d'.' -f1) + echo -e " ${CYAN}${log_count})${NC} ${filename}" + echo -e " Size: ${size} | Modified: ${mod_time}" + done < <(find "$LOG_DIR" -name "*.log" -type f | sort) + + if [ $log_count -eq 0 ]; then + echo -e " ${DIM}No log files found${NC}" + fi + fi + + echo "" + echo -e "${BOLD}Actions:${NC}" + echo "" + echo -e " ${GREEN}v)${NC} View Primary Log (last 100 lines)" + echo -e " ${GREEN}t)${NC} Tail Primary Log (live follow)" + echo -e " ${GREEN}s)${NC} Search Logs" + echo -e " ${GREEN}e)${NC} Show Errors Only" + echo -e " ${GREEN}a)${NC} Archive Old Logs" + echo "" + echo -e " ${RED}0)${NC} Return to Menu" + echo "" + echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" + echo -n "Select option: " +} + +# View primary log +view_primary_log() { + clear + print_banner "Acronis Primary Log (Last 100 Lines)" + echo "" + + if [ -f "$PRIMARY_LOG" ]; then + tail -100 "$PRIMARY_LOG" + echo "" + echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" + echo "" + press_enter + else + print_error "Primary log file not found: $PRIMARY_LOG" + press_enter + fi +} + +# Tail primary log +tail_primary_log() { + clear + print_banner "Acronis Live Log (Ctrl+C to Exit)" + echo "" + echo "Following: $PRIMARY_LOG" + echo "" + echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" + echo "" + + if [ -f "$PRIMARY_LOG" ]; then + tail -f "$PRIMARY_LOG" + else + print_error "Primary log file not found: $PRIMARY_LOG" + press_enter + fi +} + +# Search logs +search_logs() { + clear + print_banner "Search Acronis Logs" + echo "" + echo -n "Enter search term: " + read -r search_term + + if [ -z "$search_term" ]; then + print_error "No search term provided" + press_enter + return + fi + + echo "" + echo "Searching for: ${search_term}" + echo "" + echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" + echo "" + + # Search all log files + local found=false + while IFS= read -r log_file; do + if grep -qi "$search_term" "$log_file" 2>/dev/null; then + found=true + echo -e "${BOLD}$(basename "$log_file"):${NC}" + grep -i --color=always "$search_term" "$log_file" | tail -20 + echo "" + fi + done < <(find "$LOG_DIR" -name "*.log" -type f) + + if [ "$found" = false ]; then + echo "No matches found for: $search_term" + fi + + echo "" + echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" + echo "" + press_enter +} + +# Show errors only +show_errors() { + clear + print_banner "Acronis Errors (Last 50)" + echo "" + + if [ -f "$PRIMARY_LOG" ]; then + echo "Filtering for ERROR, WARN, FAIL, CRITICAL..." + echo "" + echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" + echo "" + + grep -iE "error|warn|fail|critical" "$PRIMARY_LOG" | tail -50 | while IFS= read -r line; do + # Color code by severity + if echo "$line" | grep -qi "critical"; then + echo -e "${RED}${BOLD}${line}${NC}" + elif echo "$line" | grep -qi "error"; then + echo -e "${RED}${line}${NC}" + elif echo "$line" | grep -qi "warn"; then + echo -e "${YELLOW}${line}${NC}" + else + echo "$line" + fi + done + + echo "" + echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" + echo "" + else + print_error "Primary log file not found" + fi + + press_enter +} + +# Archive old logs +archive_old_logs() { + clear + print_banner "Archive Old Logs" + echo "" + + # Calculate total size + local total_size=$(du -sh "$LOG_DIR" 2>/dev/null | awk '{print $1}') + local log_count=$(find "$LOG_DIR" -name "*.log" -type f | wc -l) + + echo "Current log status:" + echo " Directory: $LOG_DIR" + echo " Total size: $total_size" + echo " Log files: $log_count" + echo "" + + # Find old logs (older than 30 days) + local old_logs=$(find "$LOG_DIR" -name "*.log" -type f -mtime +30 2>/dev/null | wc -l) + + if [ $old_logs -eq 0 ]; then + echo -e "${GREEN}✓ No old logs found (>30 days)${NC}" + echo "" + press_enter + return + fi + + echo "Found $old_logs log file(s) older than 30 days" + echo "" + echo "Archive location: /root/acronis-logs-archive-$(date +%Y%m%d).tar.gz" + echo "" + echo -n "Create archive and remove old logs? (yes/no): " + read -r confirm + + if [ "$confirm" != "yes" ]; then + echo "" + echo "Archive cancelled" + press_enter + return + fi + + echo "" + echo "→ Creating archive..." + + # Create archive + local archive_name="/root/acronis-logs-archive-$(date +%Y%m%d).tar.gz" + if find "$LOG_DIR" -name "*.log" -type f -mtime +30 -print0 2>/dev/null | tar -czf "$archive_name" --null -T -; then + print_success "Archive created: $archive_name" + + # Remove old logs + echo "" + echo "→ Removing old logs..." + find "$LOG_DIR" -name "*.log" -type f -mtime +30 -delete 2>/dev/null + + local remaining=$(find "$LOG_DIR" -name "*.log" -type f | wc -l) + echo "" + print_success "Old logs archived and removed" + echo "" + echo "Remaining log files: $remaining" + else + print_error "Failed to create archive" + fi + + echo "" + press_enter +} + +# Main loop +while true; do + show_log_menu + read -r choice + + case $choice in + v) view_primary_log ;; + t) tail_primary_log ;; + s) search_logs ;; + e) show_errors ;; + a) archive_old_logs ;; + 0) exit 0 ;; + *) + # Check if numeric selection for specific log file + if [[ "$choice" =~ ^[0-9]+$ ]]; then + log_files=($(find "$LOG_DIR" -name "*.log" -type f | sort)) + if [ $choice -gt 0 ] && [ $choice -le ${#log_files[@]} ]; then + selected_log="${log_files[$((choice-1))]}" + clear + print_banner "Log: $(basename "$selected_log")" + echo "" + tail -100 "$selected_log" + echo "" + press_enter + else + print_error "Invalid log selection" + sleep 1 + fi + else + print_error "Invalid option" + sleep 1 + fi + ;; + esac +done diff --git a/modules/backup/acronis-manual-backup.sh b/modules/backup/acronis-manual-backup.sh new file mode 100755 index 0000000..5e55c31 --- /dev/null +++ b/modules/backup/acronis-manual-backup.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +source "$SCRIPT_DIR/lib/common-functions.sh" + +if [ "$EUID" -ne 0 ]; then + print_error "This script must be run as root" + exit 1 +fi + +print_banner "Create Manual Backup" + +echo "" +echo -e "${BOLD}Manual Backup Creation${NC}" +echo "" +echo "Manual backups are triggered through the Acronis web console or CLI." +echo "" +echo -e "${CYAN}Web Console Method (Recommended):${NC}" +echo "" +echo "1. Log in to Acronis web console" +echo "2. Go to: Devices → Select this server" +echo "3. Click 'Back up now' button" +echo "4. Monitor backup progress in real-time" +echo "" +echo -e "${CYAN}Command Line Method:${NC}" +echo "" +echo "Use the Acronis CLI tool (acrocmd):" +echo "" +echo " # List available plans" +echo " acrocmd list plans" +echo "" +echo " # Run backup for specific plan" +echo " acrocmd backup run --plan " +echo "" +echo " # Create ad-hoc backup" +echo " acrocmd backup create --source /path/to/data --destination /backup/path" +echo "" +echo -e "${BOLD}Note:${NC} Detailed CLI backup functionality can be added here based on" +echo "your specific requirements. Would you like me to implement the full" +echo "CLI backup interface?" +echo "" +press_enter diff --git a/modules/backup/acronis-register.sh b/modules/backup/acronis-register.sh new file mode 100755 index 0000000..7d56db4 --- /dev/null +++ b/modules/backup/acronis-register.sh @@ -0,0 +1,231 @@ +#!/bin/bash + +################################################################################ +# Acronis Agent Registration +################################################################################ +# Purpose: Register Acronis agent with Acronis Cloud +# Command: /usr/lib/Acronis/RegisterAgentTool/RegisterAgent +# Flags: +# -o register - Operation: register +# -t cloud - Type: cloud-based +# -a - Service URL +# --token - Registration token +################################################################################ + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +source "$SCRIPT_DIR/lib/common-functions.sh" +source "$SCRIPT_DIR/lib/system-detect.sh" + +# Require root +if [ "$EUID" -ne 0 ]; then + print_error "This script must be run as root" + exit 1 +fi + +print_banner "Acronis Agent Registration" + +# Check if agent is installed +if [ ! -f "/usr/lib/Acronis/RegisterAgentTool/RegisterAgent" ]; then + echo "" + print_error "Acronis agent is not installed" + echo "" + echo "Please install the agent first:" + echo " 1. Return to Acronis Management menu" + echo " 2. Select 'Install Acronis Agent'" + echo "" + press_enter + exit 1 +fi + +echo "" + +# Check current registration status +echo -e "${BOLD}Current Registration Status:${NC}" +echo "" + +if [ -f "/etc/Acronis/Global.config" ]; then + if grep -q "CloudUrl" "/etc/Acronis/Global.config" 2>/dev/null; then + echo -e " ${GREEN}✓${NC} Agent is currently registered" + + # Extract current cloud URL + current_url=$(grep -oP 'CloudUrl[>="].*?https://[^"<]+' /etc/Acronis/Global.config 2>/dev/null | grep -oP 'https://[^"<]+' | head -1) + if [ -n "$current_url" ]; then + echo -e " Current URL: ${current_url}" + fi + + echo "" + echo -e "${YELLOW}⚠ Agent is already registered${NC}" + echo "" + echo "Do you want to:" + echo " 1) Keep current registration" + echo " 2) Re-register (will overwrite current registration)" + echo "" + echo -n "Select [1]: " + read -r choice + choice="${choice:-1}" + + if [ "$choice" = "1" ]; then + echo "" + echo "Keeping current registration" + press_enter + exit 0 + fi + + echo "" + echo "Proceeding with re-registration..." + else + echo -e " ${YELLOW}○${NC} Agent is not registered" + fi +else + echo -e " ${YELLOW}○${NC} No configuration found" +fi + +echo "" +echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" +echo "" +echo -e "${BOLD}Agent Registration${NC}" +echo "" +echo "You'll need:" +echo " • Acronis Cloud service URL (e.g., us5-cloud.acronis.com)" +echo " • Registration token from Acronis web console" +echo "" +echo "To get a registration token:" +echo " 1. Log in to Acronis web console" +echo " 2. Go to Settings → Registration tokens" +echo " 3. Create a new token or copy existing one" +echo "" +echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" +echo "" + +# Get service URL +echo -n "Enter Acronis Cloud service URL [us5-cloud.acronis.com]: " +read -r service_url +service_url="${service_url:-us5-cloud.acronis.com}" + +# Validate URL format +if [[ ! "$service_url" =~ ^[a-z0-9.-]+\.acronis\.com$ ]]; then + print_error "Invalid service URL format" + echo "" + echo "Expected format: region-cloud.acronis.com" + echo "Examples:" + echo " • us5-cloud.acronis.com" + echo " • eu2-cloud.acronis.com" + echo " • ap1-cloud.acronis.com" + echo "" + press_enter + exit 1 +fi + +# Get registration token +echo "" +echo -n "Enter registration token: " +read -r reg_token + +if [ -z "$reg_token" ]; then + print_error "Registration token is required" + press_enter + exit 1 +fi + +# Confirm registration +echo "" +echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" +echo "" +echo -e "${BOLD}Registration Summary:${NC}" +echo "" +echo " Service URL: https://${service_url}" +echo " Token: ${reg_token:0:8}...${reg_token: -4}" +echo "" +echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" +echo "" +echo -n "Proceed with registration? (yes/no): " +read -r confirm + +if [ "$confirm" != "yes" ]; then + echo "" + print_error "Registration cancelled" + press_enter + exit 0 +fi + +echo "" +echo -e "${BOLD}Registering Agent...${NC}" +echo "" + +# Run registration command +REGISTER_CMD="/usr/lib/Acronis/RegisterAgentTool/RegisterAgent" +REGISTER_ARGS="-o register -t cloud -a https://${service_url} --token ${reg_token}" + +echo "→ Contacting Acronis Cloud..." +echo "" +echo -e "${DIM}──────────────────────────────────────────────────────────────${NC}" + +# Execute registration +if $REGISTER_CMD $REGISTER_ARGS; then + REG_EXIT_CODE=$? +else + REG_EXIT_CODE=$? +fi + +echo -e "${DIM}──────────────────────────────────────────────────────────────${NC}" +echo "" + +# Check result +if [ $REG_EXIT_CODE -eq 0 ]; then + print_success "Registration successful!" + echo "" + + # Restart services to apply registration + echo "→ Restarting Acronis services..." + systemctl restart acronis_mms + systemctl restart aakore + sleep 2 + + if systemctl is-active --quiet acronis_mms; then + print_success "Services restarted successfully" + echo "" + + echo -e "${BOLD}Agent Registered Successfully!${NC}" + echo "" + echo "Next steps:" + echo " 1. Log in to Acronis web console:" + echo " → https://${service_url}" + echo "" + echo " 2. Find this agent in the device list" + echo " → Navigate to: Devices → All devices" + echo "" + echo " 3. Assign backup plans to this agent" + echo " → Select device → Protection → Add plan" + echo "" + echo " 4. Check agent status from this toolkit" + echo " → Select 'Check Agent Status' from Acronis menu" + echo "" + else + print_error "Services failed to restart" + echo "" + echo "Registration may have succeeded but services need attention." + echo "Check logs: tail -f /var/lib/Acronis/BackupAndRecovery/MMS/mms.0.log" + echo "" + fi + +else + print_error "Registration failed with exit code $REG_EXIT_CODE" + echo "" + echo "Common issues:" + echo " • Invalid registration token" + echo " • Incorrect service URL" + echo " • Network connectivity issues" + echo " • Firewall blocking connection to Acronis Cloud" + echo " • Token already used or expired" + echo "" + echo "Troubleshooting:" + echo " 1. Verify token in Acronis web console" + echo " 2. Check network connectivity:" + echo " curl -I https://${service_url}" + echo "" + echo " 3. Check agent logs:" + echo " tail -f /var/lib/Acronis/BackupAndRecovery/MMS/mms.0.log" + echo "" +fi + +press_enter diff --git a/modules/backup/acronis-restore.sh b/modules/backup/acronis-restore.sh new file mode 100755 index 0000000..e56a16a --- /dev/null +++ b/modules/backup/acronis-restore.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +source "$SCRIPT_DIR/lib/common-functions.sh" + +if [ "$EUID" -ne 0 ]; then + print_error "This script must be run as root" + exit 1 +fi + +print_banner "Restore from Backup" + +echo "" +echo -e "${RED}${BOLD}⚠️ RESTORE OPERATION ⚠️${NC}" +echo "" +echo "Restoring from backups requires careful planning to avoid data loss." +echo "" +echo -e "${BOLD}Restore Methods:${NC}" +echo "" +echo -e "${CYAN}1. Web Console Method (Recommended)${NC}" +echo " • Most user-friendly with visual interface" +echo " • Full preview of backup contents" +echo " • Granular file/folder selection" +echo "" +echo " Steps:" +echo " a) Log in to Acronis web console" +echo " b) Navigate to: Backup → Recovery" +echo " c) Select backup archive" +echo " d) Choose recovery point (date/time)" +echo " e) Select files/folders to restore" +echo " f) Choose restore destination" +echo " g) Start recovery process" +echo "" +echo -e "${CYAN}2. Command Line Method${NC}" +echo " • For advanced users and automation" +echo " • Requires acrocmd CLI tool" +echo "" +echo " Basic syntax:" +echo " acrocmd recover --archive \\" +echo " --recoverypoint \\" +echo " --destination /restore/path" +echo "" +echo -e "${CYAN}3. Bootable Media Recovery${NC}" +echo " • For full system disaster recovery" +echo " • Boot from Acronis bootable USB/ISO" +echo " • Restore entire system image" +echo "" +echo -e "${BOLD}Important Notes:${NC}" +echo "" +echo " ⚠ Test restores in a non-production environment first" +echo " ⚠ Verify backup integrity before critical restores" +echo " ⚠ Consider restoring to alternate location first" +echo " ⚠ Backup current data before overwriting" +echo "" +echo "Would you like me to implement an interactive restore wizard" +echo "with CLI backup browsing and restore capabilities?" +echo "" +press_enter diff --git a/modules/backup/acronis-status.sh b/modules/backup/acronis-status.sh new file mode 100755 index 0000000..f2e92a2 --- /dev/null +++ b/modules/backup/acronis-status.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +source "$SCRIPT_DIR/lib/common-functions.sh" + +if [ "$EUID" -ne 0 ]; then + print_error "This script must be run as root" + exit 1 +fi + +print_banner "View Backup Status" + +echo "" +echo -e "${BOLD}Acronis Backup Status${NC}" +echo "" +echo "Checking backup status..." +echo "" + +# Check if acrocmd exists +if ! command -v acrocmd &>/dev/null; then + echo -e "${YELLOW}acrocmd CLI tool not found${NC}" + echo "" + echo "Backup status is available through:" + echo " • Acronis web console (real-time status)" + echo " • Agent logs (see 'View Logs' option)" + echo "" + echo "To use CLI: acrocmd may need to be installed separately" + echo "" + press_enter + exit 0 +fi + +# Show recent backup activities from logs +if [ -f "/var/lib/Acronis/BackupAndRecovery/MMS/mms.0.log" ]; then + echo -e "${BOLD}Recent Backup Activity:${NC}" + echo "" + grep -i "backup.*completed\|backup.*started\|backup.*failed" /var/lib/Acronis/BackupAndRecovery/MMS/mms.0.log 2>/dev/null | tail -10 + echo "" +fi + +echo "For detailed status, use:" +echo " • Web console: Full backup history and status" +echo " • acrocmd: Command-line status queries" +echo "" +press_enter diff --git a/modules/backup/acronis-uninstall.sh b/modules/backup/acronis-uninstall.sh new file mode 100755 index 0000000..dcd594a --- /dev/null +++ b/modules/backup/acronis-uninstall.sh @@ -0,0 +1,249 @@ +#!/bin/bash + +################################################################################ +# Acronis Agent Uninstaller +################################################################################ +# Purpose: Safely uninstall Acronis Cyber Protect agent +# Process: +# 1. Stop all Acronis services +# 2. Unregister from cloud (optional) +# 3. Remove Acronis packages +# 4. Clean up data directories (optional) +################################################################################ + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +source "$SCRIPT_DIR/lib/common-functions.sh" +source "$SCRIPT_DIR/lib/system-detect.sh" + +# Require root +if [ "$EUID" -ne 0 ]; then + print_error "This script must be run as root" + exit 1 +fi + +print_banner "Acronis Agent Uninstaller" + +# Check if Acronis is installed +if ! systemctl list-unit-files | grep -q "acronis_mms.service"; then + echo "" + echo -e "${YELLOW}⚠ Acronis Not Installed${NC}" + echo "" + echo "Acronis Cyber Protect does not appear to be installed on this system." + echo "" + press_enter + exit 0 +fi + +echo "" +echo -e "${RED}${BOLD}⚠️ WARNING ⚠️${NC}" +echo "" +echo "This will completely remove Acronis Cyber Protect from this system." +echo "" +echo -e "${BOLD}What will be removed:${NC}" +echo " • All Acronis services (aakore, mms, schedule, active-protection)" +echo " • Acronis software packages" +echo " • Agent registration (if selected)" +echo " • Backup data and logs (if selected)" +echo "" +echo -e "${RED}This action cannot be easily undone!${NC}" +echo "" +echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" +echo "" + +# Confirm uninstallation +echo -n "Type 'uninstall' to confirm removal: " +read -r confirm + +if [ "$confirm" != "uninstall" ]; then + echo "" + print_error "Uninstallation cancelled" + press_enter + exit 0 +fi + +echo "" +echo -e "${BOLD}Uninstallation Options:${NC}" +echo "" + +# Ask about data retention +echo -n "Remove backup data and logs? (yes/no) [no]: " +read -r remove_data +remove_data="${remove_data:-no}" + +echo "" +echo -n "Unregister from Acronis Cloud? (yes/no) [yes]: " +read -r unregister +unregister="${unregister:-yes}" + +echo "" +echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" +echo "" +echo -e "${BOLD}Uninstallation Summary:${NC}" +echo "" +echo " Stop services: Yes" +echo " Remove software: Yes" +echo " Unregister agent: ${unregister}" +echo " Remove data/logs: ${remove_data}" +echo "" +echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" +echo "" +echo -n "Proceed with uninstallation? (yes/no): " +read -r final_confirm + +if [ "$final_confirm" != "yes" ]; then + echo "" + print_error "Uninstallation cancelled" + press_enter + exit 0 +fi + +echo "" +echo -e "${BOLD}Starting Uninstallation...${NC}" +echo "" + +# Stop all services +echo "→ Stopping Acronis services..." +systemctl stop active-protection.service 2>/dev/null +systemctl stop acronis_schedule 2>/dev/null +systemctl stop acronis_mms 2>/dev/null +systemctl stop aakore 2>/dev/null +service acronis_mms stop 2>/dev/null + +sleep 2 + +if systemctl is-active --quiet acronis_mms; then + print_error "Warning: Some services may still be running" +else + print_success "Services stopped" +fi + +echo "" + +# Unregister from cloud if requested +if [ "$unregister" = "yes" ]; then + echo "→ Unregistering from Acronis Cloud..." + + if [ -f "/usr/lib/Acronis/RegisterAgentTool/RegisterAgent" ]; then + if /usr/lib/Acronis/RegisterAgentTool/RegisterAgent -o unregister 2>/dev/null; then + print_success "Agent unregistered" + else + echo " ${YELLOW}Note: Unregistration may have failed (continuing anyway)${NC}" + fi + else + echo " ${YELLOW}Note: Registration tool not found (skipping)${NC}" + fi + + echo "" +fi + +# Disable services +echo "→ Disabling Acronis services..." +systemctl disable aakore 2>/dev/null +systemctl disable acronis_mms 2>/dev/null +systemctl disable acronis_schedule 2>/dev/null +systemctl disable active-protection.service 2>/dev/null +echo " ${GREEN}✓${NC} Services disabled" +echo "" + +# Remove packages +echo "→ Removing Acronis packages..." + +# Try different package managers +if command -v dpkg &>/dev/null; then + # Debian/Ubuntu + dpkg -l | grep -i acronis | awk '{print $2}' | while read -r pkg; do + echo " Removing: $pkg" + dpkg --purge "$pkg" 2>/dev/null + done +elif command -v rpm &>/dev/null; then + # RedHat/CentOS + rpm -qa | grep -i acronis | while read -r pkg; do + echo " Removing: $pkg" + rpm -e "$pkg" 2>/dev/null + done +fi + +print_success "Packages removed" +echo "" + +# Remove data directories if requested +if [ "$remove_data" = "yes" ]; then + echo "→ Removing Acronis data and logs..." + + declare -a DATA_DIRS=( + "/var/lib/Acronis" + "/usr/lib/Acronis" + "/etc/Acronis" + "/opt/acronis" + ) + + for dir in "${DATA_DIRS[@]}"; do + if [ -d "$dir" ]; then + local size=$(du -sh "$dir" 2>/dev/null | awk '{print $1}') + echo " Removing: $dir (${size})" + rm -rf "$dir" 2>/dev/null + fi + done + + print_success "Data directories removed" + echo "" +fi + +# Clean up systemd +echo "→ Cleaning up system configuration..." +systemctl daemon-reload +echo " ${GREEN}✓${NC} systemd reloaded" +echo "" + +# Final verification +echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}" +echo "" +echo -e "${GREEN}${BOLD}✓ Uninstallation Complete${NC}" +echo "" + +# Check if anything remains +local remaining=0 + +if systemctl list-unit-files | grep -q "acronis"; then + echo -e "${YELLOW}⚠ Some service files may still be present${NC}" + ((remaining++)) +fi + +if [ -d "/var/lib/Acronis" ] || [ -d "/usr/lib/Acronis" ]; then + echo -e "${YELLOW}⚠ Some directories were not removed${NC}" + ((remaining++)) +fi + +if [ $remaining -eq 0 ]; then + echo "Acronis Cyber Protect has been completely removed from this system." +else + echo "" + echo "Uninstallation mostly complete, but some files may remain." + echo "This is usually safe and won't affect system operation." +fi + +echo "" + +# Show what was kept +if [ "$remove_data" = "no" ]; then + echo -e "${BOLD}Retained Data:${NC}" + echo "" + echo "Backup data and logs were kept as requested:" + if [ -d "/var/lib/Acronis" ]; then + local data_size=$(du -sh /var/lib/Acronis 2>/dev/null | awk '{print $1}') + echo " Location: /var/lib/Acronis" + echo " Size: $data_size" + echo "" + echo "To remove this data later:" + echo " rm -rf /var/lib/Acronis" + fi + echo "" +fi + +echo "To reinstall Acronis in the future:" +echo " 1. Return to Backup & Recovery menu" +echo " 2. Select 'Acronis Management'" +echo " 3. Choose 'Install Acronis Agent'" +echo "" + +press_enter diff --git a/modules/backup/acronis-update.sh b/modules/backup/acronis-update.sh new file mode 100755 index 0000000..b899c8b --- /dev/null +++ b/modules/backup/acronis-update.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +source "$SCRIPT_DIR/lib/common-functions.sh" + +if [ "$EUID" -ne 0 ]; then + print_error "This script must be run as root" + exit 1 +fi + +print_banner "Update Acronis Agent" + +echo "" +echo -e "${BOLD}Acronis Agent Update${NC}" +echo "" + +# Check current version +echo "→ Checking current agent version..." +if [ -f "/usr/lib/Acronis/BackupAndRecovery/aakore" ]; then + current_version=$(/usr/lib/Acronis/BackupAndRecovery/aakore --version 2>/dev/null | head -1 || echo "Unknown") + echo " Current version: ${current_version}" +else + print_error "Acronis agent not found" + press_enter + exit 1 +fi + +echo "" +echo -e "${BOLD}Update Methods:${NC}" +echo "" +echo -e "${CYAN}1. Automatic Update (via Acronis Cloud)${NC}" +echo " • Managed from web console" +echo " • Navigate to: Settings → Agent updates" +echo " • Enable automatic updates or schedule manually" +echo "" +echo -e "${CYAN}2. Manual Update (Download + Install)${NC}" +echo " • Download latest agent installer" +echo " • Install over existing agent" +echo " • Preserves configuration and registration" +echo "" +echo -n "Select update method (1/2) or 0 to cancel [1]: " +read -r method +method="${method:-1}" + +case "$method" in + 1) + echo "" + echo "Automatic updates are managed through Acronis Cloud." + echo "" + echo "To enable:" + echo " 1. Log in to Acronis web console" + echo " 2. Go to: Settings → Agent updates" + echo " 3. Configure update policy for this agent" + echo "" + ;; + 2) + echo "" + echo "Manual update will download and install the latest agent." + echo "" + echo -n "Proceed with manual update? (yes/no): " + read -r confirm + if [ "$confirm" = "yes" ]; then + echo "" + echo "→ This will run the installer in upgrade mode..." + echo "" + echo "Note: You can use the 'Install Acronis Agent' option" + echo "which will detect existing installation and offer upgrade." + echo "" + fi + ;; + *) + echo "" + echo "Update cancelled" + ;; +esac + +echo "" +press_enter