Add comprehensive Acronis backup management interface

Implemented complete backup management section with acrocmd integration:

New Features:
- Backup Manager: Centralized interface with organized sections
  • Agent Management (status, logs)
  • Backup Operations (list, trigger, status)
  • Plan Management (view, manage protection plans)
  • Restore Operations (placeholder for future)

Scripts Created:
- acronis-backup-manager.sh: Main backup management menu
- acronis-list-backups.sh: Lists archives and backup details
- acronis-trigger-backup.sh: Triggers manual backups with plan selection
- acronis-backup-status.sh: Shows active tasks and recent activities
- acronis-schedule-viewer.sh: Displays protection plans and schedules
- acronis-plan-manager.sh: Manages protection plans (view/enable/disable/delete)

Integration:
- All scripts use acrocmd CLI for programmatic backup operations
- Updated Acronis menu with streamlined "Manage Backups" option
- Reorganized menu structure for better usability
- Added proper error handling and status checks

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
cschantz
2025-11-06 16:25:10 -05:00
parent acad96bf93
commit bfbddf363a
7 changed files with 788 additions and 42 deletions
+14 -22
View File
@@ -584,25 +584,21 @@ show_acronis_menu() {
echo "" echo ""
echo -e " ${YELLOW}1)${NC} Install Acronis Agent - Download and install Acronis" echo -e " ${YELLOW}1)${NC} Install Acronis Agent - Download and install Acronis"
echo -e " ${YELLOW}2)${NC} Register with Cloud - Connect to Acronis Cloud" echo -e " ${YELLOW}2)${NC} Register with Cloud - Connect to Acronis Cloud"
echo -e " ${YELLOW}3)${NC} Configure Backup Plans - Setup backup schedules"
echo "" echo ""
echo -e "${BOLD}Backup Operations:${NC}" echo -e "${BOLD}Backup Management:${NC}"
echo "" echo ""
echo -e " ${YELLOW}4)${NC} Create Manual Backup - Run backup now" echo -e " ${GREEN}3)${NC} 📊 Manage Backups - Complete backup management interface"
echo -e " ${YELLOW}5)${NC} View Backup Status - Check backup job status"
echo -e " ${YELLOW}6)${NC} List Available Backups - Show all backup points"
echo -e " ${YELLOW}7)${NC} Restore from Backup - Recover files/databases"
echo "" echo ""
echo -e "${BOLD}Management:${NC}" echo -e "${BOLD}Quick Actions:${NC}"
echo "" echo ""
echo -e " ${YELLOW}8)${NC} Check Agent Status - Verify Acronis is running" echo -e " ${YELLOW}4)${NC} Check Agent Status - Verify Acronis is running"
echo -e " ${YELLOW}9)${NC} Update Agent - Upgrade to latest version" echo -e " ${YELLOW}5)${NC} Update Agent - Upgrade to latest version"
echo -e " ${YELLOW}10)${NC} View Logs - Check Acronis logs" echo -e " ${YELLOW}6)${NC} View Logs - Check Acronis logs"
echo -e " ${YELLOW}11)${NC} Uninstall Acronis - Remove Acronis agent" echo -e " ${YELLOW}7)${NC} Uninstall Acronis - Remove Acronis agent"
echo "" echo ""
echo -e "${BOLD}Troubleshooting:${NC}" echo -e "${BOLD}Troubleshooting:${NC}"
echo "" echo ""
echo -e " ${RED}12)${NC} 🔧 Troubleshoot Backups - Diagnose backup failures" echo -e " ${RED}8)${NC} 🔧 Troubleshoot Backups - Diagnose backup failures"
echo "" echo ""
echo -e " ${RED}0)${NC} Back to Backup & Recovery" echo -e " ${RED}0)${NC} Back to Backup & Recovery"
echo "" echo ""
@@ -619,16 +615,12 @@ handle_acronis_menu() {
case $choice in case $choice in
1) run_module "backup" "acronis-install.sh" ;; 1) run_module "backup" "acronis-install.sh" ;;
2) run_module "backup" "acronis-register.sh" ;; 2) run_module "backup" "acronis-register.sh" ;;
3) run_module "backup" "acronis-configure.sh" ;; 3) run_module "backup" "acronis-backup-manager.sh" ;;
4) run_module "backup" "acronis-manual-backup.sh" ;; 4) run_module "backup" "acronis-agent-status.sh" ;;
5) run_module "backup" "acronis-status.sh" ;; 5) run_module "backup" "acronis-update.sh" ;;
6) run_module "backup" "acronis-list-backups.sh" ;; 6) run_module "backup" "acronis-logs.sh" ;;
7) run_module "backup" "acronis-restore.sh" ;; 7) run_module "backup" "acronis-uninstall.sh" ;;
8) run_module "backup" "acronis-agent-status.sh" ;; 8) run_module "backup" "acronis-troubleshoot.sh" ;;
9) run_module "backup" "acronis-update.sh" ;;
10) run_module "backup" "acronis-logs.sh" ;;
11) run_module "backup" "acronis-uninstall.sh" ;;
12) run_module "backup" "acronis-troubleshoot.sh" ;;
0) return ;; 0) return ;;
*) echo -e "${RED}Invalid option${NC}"; sleep 1 ;; *) echo -e "${RED}Invalid option${NC}"; sleep 1 ;;
esac esac
+103
View File
@@ -0,0 +1,103 @@
#!/bin/bash
################################################################################
# Acronis Backup Manager
################################################################################
# Purpose: Main interface for Acronis backup operations
# Features:
# - List backups and archives
# - Trigger manual backups
# - View backup schedules
# - Monitor backup/recovery status
################################################################################
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
source "$SCRIPT_DIR/lib/common-functions.sh"
source "$SCRIPT_DIR/lib/system-detect.sh"
if [ "$EUID" -ne 0 ]; then
print_error "This script must be run as root"
exit 1
fi
# Check if Acronis is installed
if ! systemctl list-unit-files | grep -q "acronis_mms.service"; then
print_error "Acronis is not installed"
echo ""
echo "Install Acronis first from the Acronis menu."
echo ""
press_enter
exit 1
fi
# Check if acrocmd is available
if [ ! -f "/usr/sbin/acrocmd" ]; then
print_error "acrocmd command-line tool not found"
echo ""
echo "This may indicate an incomplete Acronis installation."
echo ""
press_enter
exit 1
fi
while true; do
clear
print_banner "Backup Management"
echo ""
echo -e "${BOLD}Agent Management${NC}"
echo -e " ${YELLOW}1)${NC} Check Agent Status"
echo -e " ${YELLOW}2)${NC} View Agent Logs"
echo ""
echo -e "${BOLD}Backup Operations${NC}"
echo -e " ${YELLOW}3)${NC} List Backups & Archives"
echo -e " ${YELLOW}4)${NC} Trigger Manual Backup"
echo -e " ${YELLOW}5)${NC} Check Backup Status"
echo ""
echo -e "${BOLD}Plan Management${NC}"
echo -e " ${YELLOW}6)${NC} View Backup Plans/Schedules"
echo -e " ${YELLOW}7)${NC} Manage Protection Plans"
echo ""
echo -e "${BOLD}Restore Operations${NC}"
echo -e " ${YELLOW}8)${NC} Restore from Backup (Future)"
echo ""
echo -e " ${YELLOW}0)${NC} Return to Acronis Menu"
echo ""
echo -n "Select option: "
read -r choice
case "$choice" in
1)
bash "$SCRIPT_DIR/modules/backup/acronis-agent-status.sh"
;;
2)
bash "$SCRIPT_DIR/modules/backup/acronis-logs.sh"
;;
3)
bash "$SCRIPT_DIR/modules/backup/acronis-list-backups.sh"
;;
4)
bash "$SCRIPT_DIR/modules/backup/acronis-trigger-backup.sh"
;;
5)
bash "$SCRIPT_DIR/modules/backup/acronis-backup-status.sh"
;;
6)
bash "$SCRIPT_DIR/modules/backup/acronis-schedule-viewer.sh"
;;
7)
bash "$SCRIPT_DIR/modules/backup/acronis-plan-manager.sh"
;;
8)
bash "$SCRIPT_DIR/modules/backup/acronis-restore.sh"
;;
0)
exit 0
;;
*)
echo ""
print_error "Invalid option"
sleep 1
;;
esac
done
+118
View File
@@ -0,0 +1,118 @@
#!/bin/bash
################################################################################
# Acronis Backup Status
################################################################################
# Purpose: Check status of backup operations using acrocmd
# Features:
# - Show active/running backups
# - Display recent backup history
# - Show backup task status
################################################################################
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
source "$SCRIPT_DIR/lib/common-functions.sh"
source "$SCRIPT_DIR/lib/system-detect.sh"
if [ "$EUID" -ne 0 ]; then
print_error "This script must be run as root"
exit 1
fi
clear
print_banner "Backup Status"
echo ""
# Check if acrocmd is available
if [ ! -f "/usr/sbin/acrocmd" ]; then
print_error "acrocmd command-line tool not found"
echo ""
press_enter
exit 1
fi
# Show active/running tasks
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo -e "${BOLD}Active Backup Tasks${NC}"
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo ""
task_output=$(/usr/sbin/acrocmd list tasks 2>&1)
if echo "$task_output" | grep -qi "no.*tasks\|error"; then
echo -e "${GREEN}${NC} No active backup tasks running"
else
echo "$task_output"
fi
echo ""
# Show recent activities
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo -e "${BOLD}Recent Backup Activities${NC}"
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo ""
activity_output=$(/usr/sbin/acrocmd list activities 2>&1)
if echo "$activity_output" | grep -qi "no.*activities\|error"; then
echo -e "${YELLOW}No recent backup activities found${NC}"
echo ""
echo "This may indicate:"
echo " • No backups have been run yet"
echo " • Agent needs registration"
echo " • No backup plans configured"
else
echo "$activity_output" | tail -20
fi
echo ""
# Parse logs for backup status
if [ -f "/var/lib/Acronis/BackupAndRecovery/MMS/mms.0.log" ]; then
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo -e "${BOLD}Log Summary${NC}"
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo ""
# Count recent backup events
log_file="/var/lib/Acronis/BackupAndRecovery/MMS/mms.0.log"
completed=$(grep -ic "backup.*completed\|backup.*success" "$log_file" 2>/dev/null || echo "0")
failed=$(grep -ic "backup.*failed\|backup.*error" "$log_file" 2>/dev/null || echo "0")
started=$(grep -ic "backup.*started\|backup.*begin" "$log_file" 2>/dev/null || echo "0")
echo "Backup Statistics (from current log):"
echo " • Started: $started"
echo " • Completed: $completed"
echo " • Failed: $failed"
echo ""
# Show last 5 backup-related events
echo "Recent Events:"
echo ""
grep -i "backup" "$log_file" 2>/dev/null | tail -5 | while read -r line; do
# Highlight status
if echo "$line" | grep -qi "success\|completed"; then
echo -e " ${GREEN}${NC} $line"
elif echo "$line" | grep -qi "fail\|error"; then
echo -e " ${RED}${NC} $line"
else
echo "$line"
fi
done
fi
echo ""
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e "${BOLD}Options:${NC}"
echo ""
echo " • View full logs: Select 'View Agent Logs' from menu"
echo " • Trigger backup: Select 'Trigger Manual Backup'"
echo " • Troubleshoot: Use 'Troubleshoot Backups' for diagnostics"
echo ""
press_enter
+51 -20
View File
@@ -1,45 +1,76 @@
#!/bin/bash #!/bin/bash
################################################################################
# Acronis List Backups
################################################################################
# Purpose: List all backups and archives using acrocmd
# Features:
# - Show backup archives
# - Show backup versions
# - Display backup details (size, date, location)
################################################################################
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
source "$SCRIPT_DIR/lib/common-functions.sh" source "$SCRIPT_DIR/lib/common-functions.sh"
source "$SCRIPT_DIR/lib/system-detect.sh"
if [ "$EUID" -ne 0 ]; then if [ "$EUID" -ne 0 ]; then
print_error "This script must be run as root" print_error "This script must be run as root"
exit 1 exit 1
fi fi
print_banner "List Available Backups" clear
print_banner "List Backups & Archives"
echo "" echo ""
echo -e "${BOLD}Available Backups${NC}" echo -e "${BOLD}Retrieving backup information...${NC}"
echo "" echo ""
# Check if acrocmd exists # Check if acrocmd is available
if ! command -v acrocmd &>/dev/null; then if [ ! -f "/usr/sbin/acrocmd" ]; then
echo -e "${YELLOW}acrocmd CLI tool not found${NC}" print_error "acrocmd command-line tool not found"
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 "" echo ""
press_enter press_enter
exit 0 exit 1
fi fi
echo "Querying backup archives..." # List archives
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo -e "${BOLD}Backup Archives${NC}"
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo "" echo ""
# Try to list archives if /usr/sbin/acrocmd list archives 2>/dev/null | grep -q .; then
if acrocmd list archives 2>/dev/null; then /usr/sbin/acrocmd list archives 2>/dev/null
echo ""
else else
echo "No archives found or command failed" echo -e "${YELLOW}No backup archives found${NC}"
echo "" echo ""
echo "Possible reasons:"
echo " • No backups have been created yet"
echo " • Agent not registered with Acronis Cloud"
echo " • No backup plans configured"
fi fi
echo ""
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo -e "${BOLD}Backup Details${NC}"
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo ""
if /usr/sbin/acrocmd list backups 2>/dev/null | grep -q .; then
/usr/sbin/acrocmd list backups 2>/dev/null
else
echo -e "${YELLOW}No backup details available${NC}"
fi
echo ""
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e "${BOLD}Options:${NC}"
echo ""
echo " • Create backups via 'Trigger Manual Backup'"
echo " • Configure plans in Acronis web console"
echo " • Check backup status for active operations"
echo ""
press_enter press_enter
+210
View File
@@ -0,0 +1,210 @@
#!/bin/bash
################################################################################
# Acronis Plan Manager
################################################################################
# Purpose: Manage Acronis protection plans
# Features:
# - List protection plans
# - View plan details
# - Enable/disable plans
# - Guidance for plan configuration
################################################################################
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
source "$SCRIPT_DIR/lib/common-functions.sh"
source "$SCRIPT_DIR/lib/system-detect.sh"
if [ "$EUID" -ne 0 ]; then
print_error "This script must be run as root"
exit 1
fi
clear
print_banner "Protection Plan Management"
echo ""
# Check if acrocmd is available
if [ ! -f "/usr/sbin/acrocmd" ]; then
print_error "acrocmd command-line tool not found"
echo ""
press_enter
exit 1
fi
# List plans
echo -e "${BOLD}Current Protection Plans${NC}"
echo ""
plan_output=$(/usr/sbin/acrocmd list plans 2>&1)
if echo "$plan_output" | grep -qi "error\|no.*plans"; then
echo -e "${YELLOW}No protection plans configured${NC}"
HAS_PLANS=false
else
echo "$plan_output"
HAS_PLANS=true
fi
echo ""
echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}"
echo ""
if [ "$HAS_PLANS" = true ]; then
echo -e "${BOLD}Plan Management Options${NC}"
echo ""
echo " 1) View detailed plan information"
echo " 2) Enable/disable plan"
echo " 3) Delete plan"
echo " 4) Create new plan (via web console)"
echo " 0) Return"
echo ""
echo -n "Select option [0]: "
read -r choice
choice="${choice:-0}"
case "$choice" in
1)
echo ""
echo -n "Enter plan ID or name: "
read -r plan_id
if [ -n "$plan_id" ]; then
echo ""
echo -e "${BOLD}Plan Details:${NC}"
echo ""
/usr/sbin/acrocmd show plan "$plan_id" 2>&1 || {
echo ""
print_error "Could not retrieve plan details"
echo "Check that the plan ID/name is correct"
}
fi
;;
2)
echo ""
echo -n "Enter plan ID to enable/disable: "
read -r plan_id
if [ -n "$plan_id" ]; then
echo ""
echo " 1) Enable plan"
echo " 2) Disable plan"
echo ""
echo -n "Select [1]: "
read -r action
action="${action:-1}"
if [ "$action" = "1" ]; then
/usr/sbin/acrocmd plan enable "$plan_id" 2>&1 && {
print_success "Plan enabled"
} || {
print_error "Failed to enable plan"
}
else
/usr/sbin/acrocmd plan disable "$plan_id" 2>&1 && {
print_success "Plan disabled"
} || {
print_error "Failed to disable plan"
}
fi
fi
;;
3)
echo ""
echo -e "${RED}${BOLD}Delete Protection Plan${NC}"
echo ""
echo -e "${YELLOW}Warning:${NC} This will delete the plan configuration."
echo "Existing backups will be retained."
echo ""
echo -n "Enter plan ID to delete: "
read -r plan_id
if [ -n "$plan_id" ]; then
echo ""
echo -n "Confirm deletion (type 'yes'): "
read -r confirm
if [ "$confirm" = "yes" ]; then
/usr/sbin/acrocmd delete plan "$plan_id" 2>&1 && {
print_success "Plan deleted"
} || {
print_error "Failed to delete plan"
}
else
echo "Cancelled"
fi
fi
;;
4)
echo ""
echo -e "${BOLD}Create New Protection Plan${NC}"
echo ""
echo "Protection plans are best created via the web console"
echo "for full configuration options and validation."
echo ""
echo -e "${CYAN}Web Console Method:${NC}"
echo ""
echo "1. Log in to Acronis web console"
# Get cloud URL
if [ -f "/etc/Acronis/Global.config" ]; then
cloud_url=$(grep -oP 'CloudUrl[>=\"].*?https://[^\"<]+' /etc/Acronis/Global.config 2>/dev/null | grep -oP 'https://[^\"<]+' | head -1)
if [ -n "$cloud_url" ]; then
echo " ${cloud_url}"
fi
fi
echo ""
echo "2. Navigate to: Devices → Select this server"
echo "3. Click 'Add protection plan'"
echo "4. Configure plan settings:"
echo " • What to back up (entire system/volumes/files)"
echo " • Where to store (cloud/local)"
echo " • When to run (schedule)"
echo " • How long to keep (retention)"
echo "5. Save and activate"
echo ""
echo -e "${BOLD}Advanced CLI Method:${NC}"
echo ""
echo "For advanced users, plans can be created via acrocmd:"
echo " acrocmd create plan --help"
;;
esac
else
echo -e "${BOLD}Getting Started with Protection Plans${NC}"
echo ""
echo "Protection plans define your backup strategy:"
echo ""
echo -e "${CYAN}What:${NC} Files, folders, volumes, or entire system"
echo -e "${CYAN}Where:${NC} Cloud storage or local destination"
echo -e "${CYAN}When:${NC} Scheduled times (hourly/daily/weekly/monthly)"
echo -e "${CYAN}Keep:${NC} Retention policy (days/versions to keep)"
echo ""
echo -e "${BOLD}To Create Your First Plan:${NC}"
echo ""
echo "1. Log in to Acronis web console"
# Get cloud URL
if [ -f "/etc/Acronis/Global.config" ]; then
cloud_url=$(grep -oP 'CloudUrl[>=\"].*?https://[^\"<]+' /etc/Acronis/Global.config 2>/dev/null | grep -oP 'https://[^\"<]+' | head -1)
if [ -n "$cloud_url" ]; then
echo " ${cloud_url}"
fi
fi
echo ""
echo "2. Navigate to: Devices → This server"
echo "3. Click 'Add protection plan'"
echo "4. Follow the configuration wizard"
echo "5. Activate the plan"
echo ""
echo -e "${GREEN}Tip:${NC} Start with a simple file backup plan to test,"
echo " then create full system backup plans as needed."
fi
echo ""
press_enter
+109
View File
@@ -0,0 +1,109 @@
#!/bin/bash
################################################################################
# Acronis Schedule Viewer
################################################################################
# Purpose: View backup schedules and protection plans
# Features:
# - List all protection plans
# - Show backup schedules
# - Display plan details
################################################################################
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
source "$SCRIPT_DIR/lib/common-functions.sh"
source "$SCRIPT_DIR/lib/system-detect.sh"
if [ "$EUID" -ne 0 ]; then
print_error "This script must be run as root"
exit 1
fi
clear
print_banner "Backup Plans & Schedules"
echo ""
# Check if acrocmd is available
if [ ! -f "/usr/sbin/acrocmd" ]; then
print_error "acrocmd command-line tool not found"
echo ""
press_enter
exit 1
fi
# List protection plans
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo -e "${BOLD}Protection Plans${NC}"
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo ""
plan_output=$(/usr/sbin/acrocmd list plans 2>&1)
if echo "$plan_output" | grep -qi "error\|no.*plans"; then
echo -e "${YELLOW}No protection plans found${NC}"
echo ""
echo "Protection plans define what, when, and how to back up."
echo ""
echo -e "${BOLD}To Create Protection Plans:${NC}"
echo ""
echo "1. Log in to Acronis web console"
# Try to get cloud URL
if [ -f "/etc/Acronis/Global.config" ]; then
cloud_url=$(grep -oP 'CloudUrl[>=\"].*?https://[^\"<]+' /etc/Acronis/Global.config 2>/dev/null | grep -oP 'https://[^\"<]+' | head -1)
if [ -n "$cloud_url" ]; then
echo " ${cloud_url}"
fi
fi
echo ""
echo "2. Navigate to: Devices → Select this server"
echo "3. Click 'Add protection plan'"
echo "4. Configure:"
echo " • Backup source (files/folders/volumes)"
echo " • Backup destination (cloud/local)"
echo " • Schedule (hourly/daily/weekly/monthly)"
echo " • Retention policy"
echo "5. Save and activate plan"
else
echo "$plan_output"
fi
echo ""
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo ""
# Check schedule status from service
echo -e "${BOLD}Schedule Service Status${NC}"
echo ""
if systemctl is-active --quiet acronis_schedule 2>/dev/null; then
echo -e "${GREEN}${NC} Acronis scheduler is running"
# Show recent schedule events from log
if [ -f "/var/lib/Acronis/BackupAndRecovery/scheduler.log" ]; then
echo ""
echo "Recent scheduler activity:"
echo ""
tail -5 /var/lib/Acronis/BackupAndRecovery/scheduler.log 2>/dev/null | while read -r line; do
echo " $line"
done
fi
else
echo -e "${YELLOW}${NC} Acronis scheduler is not running"
echo ""
echo "Start it with: systemctl start acronis_schedule"
fi
echo ""
echo -e "${CYAN}════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e "${BOLD}Next Steps:${NC}"
echo ""
echo " • Trigger manual backup: Select 'Trigger Manual Backup'"
echo " • Manage plans: Select 'Manage Protection Plans'"
echo " • Check status: Select 'Check Backup Status'"
echo ""
press_enter
+183
View File
@@ -0,0 +1,183 @@
#!/bin/bash
################################################################################
# Acronis Trigger Backup
################################################################################
# Purpose: Trigger manual backups using acrocmd
# Features:
# - List available backup plans
# - Run backup for specific plan
# - Trigger ad-hoc backup
################################################################################
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
source "$SCRIPT_DIR/lib/common-functions.sh"
source "$SCRIPT_DIR/lib/system-detect.sh"
if [ "$EUID" -ne 0 ]; then
print_error "This script must be run as root"
exit 1
fi
clear
print_banner "Trigger Manual Backup"
echo ""
# Check if acrocmd is available
if [ ! -f "/usr/sbin/acrocmd" ]; then
print_error "acrocmd command-line tool not found"
echo ""
press_enter
exit 1
fi
# List available plans
echo -e "${BOLD}Available Backup Plans${NC}"
echo ""
echo "Querying backup plans from Acronis..."
echo ""
plan_output=$(/usr/sbin/acrocmd list plans 2>&1)
if echo "$plan_output" | grep -qi "error\|failed\|no plans"; then
echo -e "${YELLOW}No backup plans found or error querying plans${NC}"
echo ""
echo "Possible reasons:"
echo " • No backup plans configured yet"
echo " • Agent not registered with Acronis Cloud"
echo " • Need to configure plans in web console first"
echo ""
echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}"
echo ""
echo -e "${BOLD}To Configure Backup Plans:${NC}"
echo ""
echo "1. Log in to Acronis web console"
echo "2. Navigate to: Devices → Select this server"
echo "3. Click 'Add protection plan'"
echo "4. Configure backup settings and schedule"
echo "5. Return here to trigger backups"
echo ""
press_enter
exit 0
fi
echo "$plan_output"
echo ""
echo -e "${CYAN}──────────────────────────────────────────────────────────────${NC}"
echo ""
echo -e "${BOLD}Trigger Backup Options:${NC}"
echo ""
echo " 1) Run backup for specific plan (by ID)"
echo " 2) Run all protection plans"
echo " 3) Web console method (recommended)"
echo " 0) Cancel"
echo ""
echo -n "Select option [3]: "
read -r choice
choice="${choice:-3}"
case "$choice" in
1)
echo ""
echo -n "Enter plan ID (or name) from list above: "
read -r plan_id
if [ -z "$plan_id" ]; then
print_error "Plan ID/name required"
press_enter
exit 1
fi
echo ""
echo -e "${BOLD}Starting Backup...${NC}"
echo ""
echo "Triggering backup for plan: $plan_id"
echo ""
# Try to run backup
if /usr/sbin/acrocmd backup run --plan "$plan_id" 2>&1; then
echo ""
print_success "Backup initiated successfully"
echo ""
echo "Monitor progress with 'Check Backup Status'"
else
echo ""
print_error "Failed to start backup"
echo ""
echo "Check that:"
echo " • Plan ID/name is correct"
echo " • Agent is online and registered"
echo " • No conflicting backups running"
fi
;;
2)
echo ""
echo -e "${BOLD}Running All Protection Plans${NC}"
echo ""
echo -e "${YELLOW}Warning:${NC} This will trigger backups for ALL configured plans."
echo ""
echo -n "Continue? (yes/no): "
read -r confirm
if [[ ! "$confirm" =~ ^[Yy]([Ee][Ss])?$ ]]; then
echo ""
echo "Cancelled"
press_enter
exit 0
fi
echo ""
echo "Triggering all protection plans..."
echo ""
if /usr/sbin/acrocmd backup run --all 2>&1; then
echo ""
print_success "All backups initiated"
echo ""
echo "Monitor progress with 'Check Backup Status'"
else
echo ""
print_error "Failed to start backups"
fi
;;
3)
# Web console method
echo ""
echo -e "${BOLD}Web Console Method${NC}"
echo ""
echo "Steps to trigger backup via web console:"
echo ""
echo "1. Log in to Acronis web console"
# Try to get cloud URL
if [ -f "/etc/Acronis/Global.config" ]; then
cloud_url=$(grep -oP 'CloudUrl[>=\"].*?https://[^\"<]+' /etc/Acronis/Global.config 2>/dev/null | grep -oP 'https://[^\"<]+' | head -1)
if [ -n "$cloud_url" ]; then
echo " ${cloud_url}"
fi
fi
echo ""
echo "2. Navigate to: Devices → Select this server"
echo "3. Click 'Back up now' button"
echo "4. Confirm backup settings"
echo "5. Monitor progress in real-time"
echo ""
echo -e "${GREEN}Benefits:${NC}"
echo " ✓ Visual progress monitoring"
echo " ✓ Detailed status updates"
echo " ✓ Easy cancellation if needed"
echo " ✓ Automatic error notifications"
;;
0|*)
echo ""
echo "Cancelled"
;;
esac
echo ""
press_enter