mb-backup-manager/manifest.jps

393 lines
13 KiB
Plaintext

type: update
jpsVersion: 1.8
name: MightyBox WordPress Backup/Restore Addon
id: mb-backup-manager
description: Custom Backup and Restore Addon for WordPress using Restic. Supports backing up databases, core files, media files, and full backups with scheduling and retention policies.
baseUrl: https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main
targetNodes:
nodeType:
- nginxphp
- litespeedphp
- lemp
- llsmp
globals:
envName: "${env.name}"
scriptPath: "/home/litespeed/mb-backups"
logPath: "/home/litespeed/mb-backups/logs"
onInstall:
- checkAddons
- installRestic
- importScripts
settings:
backupSettings:
submitUnchanged: true
fields:
- name: blabel
caption: Backup Label
type: string
restoreSettings:
submitUnchanged: true
fields:
- name: snapshotId
caption: Snapshot ID
type: string
fullRestoreSettings:
submitUnchanged: true
fields:
- name: backupSessionTag
caption: Backup Session Tag
type: string
placeholder: "e.g., manual-backup-2024-01-15_10-30-45"
buttons:
- caption: Backup Now
action: backupnow
loadingText: Backing up...
confirmText: Do you want to initiate the backup process?
successText: The backup process has been finished successfully.
- caption: Full Backup Session Restore
action: restoreFullBackupSession
loadingText: Restoring full backup session...
confirmText: Restore complete backup session? This will restore database, core files, and media files from the same backup session.
successText: Full backup session restoration completed successfully
settings: fullRestoreSettings
menu:
- caption: Configure Auto Backup
action: configureAutoBackup
confirmText: Configure automated backup schedule?
loadingText: Setting up backup schedule...
successText: Backup schedule configured successfully
title: Configure Automated Backup Schedule
submitButtonText: Save Schedule
- caption: List Scheduled Backups
action: listScheduledBackups
confirmText: List scheduled backups?
loadingText: Listing scheduled backups...
successText: Scheduled backups listed successfully
- caption: Remove Auto Backup
action: removeAutoBackup
confirmText: Remove automated backup schedule?
loadingText: Removing backup schedule...
successText: Backup schedule removed successfully
- caption: View Schedule
action: viewBackupSchedule
confirmText: View current backup schedule?
successText: Current schedule retrieved successfully
- caption: Check Backup Repository
confirmText: Do you want to check and repair the backup repository?
loadingText: Checking and repairing backup repository...
action: checkBackupRepo
successText: Backup repository check completed successfully.
title: Check Backup Repository
submitButtonText: Run Check
- caption: Core File Backup
confirmText: Backup Core Files?
loadingText: Backing up Core Files...
action: backupcore
successText: Core Files Backup Completed Successfully
settings: backupSettings
title: Backup Core Files
submitButtonText: Backup Now
- caption: Media Backup
confirmText: Backup Media Files?
loadingText: Backing up Media Files...
action: backupmedia
successText: Media Files Backup Completed Successfully
settings: backupSettings
title: Backup Media Files
submitButtonText: Backup Now
- caption: Database Backup
confirmText: Backup Database?
loadingText: Backing up Database...
action: backupdb
successText: Database Backup Completed Successfully
settings: backupSettings
title: Backup Database
submitButtonText: Backup Now
- caption: Restore
confirmText: Restore from Snapshot?
loadingText: Restoring...
action: restore
successText: Restore Completed Successfully
settings: restoreSettings
title: Restore from Snapshot
submitButtonText: Restore Now
- caption: View Backup Sessions
action: viewBackupSessions
confirmText: View available backup sessions?
loadingText: Retrieving backup sessions...
successText: Backup sessions listed successfully.
- caption: View All Backups
action: viewAllBackups
confirmText: Are you sure you want to view all backups?
successText: All backups listed successfully.
- caption: View Core Backups
action: viewCoreBackups
confirmText: Are you sure you want to view core backups?
successText: Core backups listed successfully.
- caption: View Media Backups
action: viewMediaBackups
confirmText: Are you sure you want to view media backups?
successText: Media backups listed successfully.
- caption: View Database Backups
action: viewDatabaseBackups
confirmText: Are you sure you want to view database backups?
successText: Database backups listed successfully.
- caption: Check Repository Stats
confirmText: Check repository stats?
loadingText: Checking repository stats...
action: checkRepoStats
successText: Repository stats checked successfully.
onUninstall:
- removeScripts
onBeforeDelete:
- removeScripts
onAfterRedeployContainer[cp]:
- installRestic
onAfterClone:
- script: return {result:0, jps:MANIFEST};
- install: ${response.jps}
nodeGroup: ${targetNodes.nodeGroup:cp}
settings:
cronTime: "0 * * * *"
backupCount: "5"
actions:
configureAutoBackup:
- cmd[cp]:
user: root
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"
listScheduledBackups:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/manage_backup_schedule.sh list
- return:
type: info
message: "${response.out}"
removeAutoBackup:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/manage_backup_schedule.sh remove
- return:
type: info
message: "${response.out}"
checkBackupRepo:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/check_backup_repo.sh
- return:
type: info
message: "${response.out}"
backupnow:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/backup_all.sh manual
- return:
type: info
message: "${response.out}"
backupcore:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/backup_core_files.sh "$(cat /etc/restic-password)" "${settings.blabel}"
- return:
type: info
message: "${response.out}"
backupmedia:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/backup_media.sh "$(cat /etc/restic-password)" "${settings.blabel}"
- return:
type: info
message: "${response.out}"
backupdb:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/backup_database.sh "$(cat /etc/restic-password)" "${settings.blabel}"
- return:
type: info
message: "${response.out}"
restore:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/restore_backup_direct.sh "${settings.snapshotId}"
- return:
type: info
message: "${response.out}"
viewBackupSessions:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/view_backup_sessions.sh sessions
- return:
type: info
message: "${response.out}"
restoreFullBackupSession:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/restore_full_backup_session.sh "${settings.backupSessionTag}"
- return:
type: info
message: "${response.out}"
viewAllBackups:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/view_snapshots.sh all
- return:
type: info
message: "${response.out}"
viewCoreBackups:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/view_snapshots.sh core_files
- return:
type: info
message: "${response.out}"
viewMediaBackups:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/view_snapshots.sh media_themes
- return:
type: info
message: "${response.out}"
viewDatabaseBackups:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/view_snapshots.sh wordpress_db
- return:
type: info
message: "${response.out}"
viewBackupSchedule:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/check_sched.sh
- return:
type: info
message: "${response.out}"
checkRepoStats:
- cmd[cp]:
user: root
commands: bash /home/litespeed/mb-backups/check_repo_stats.sh
- return:
type: info
message: "${response.out}"
checkAddons:
- script: |-
var onAfterReturn = { setGlobals: {} },
glbs = onAfterReturn.setGlobals,
resp = api.marketplace.app.GetAddonList({
search: {},
envName: "${env.name}",
session: session
});
if (resp.result != 0) return resp;
glbs["alreadyInstalled"] = false;
for (let i = 0, n = resp.apps.length; i < n; i++) {
if (resp.apps[i].isInstalled) {
if (resp.apps[i].app_id == 'db-backup') {
glbs["alreadyInstalled"] = true;
break;
}
}
}
return { result: 0, onAfterReturn: onAfterReturn };
- if ('${globals.alreadyInstalled}' == 'true' ):
- stopEvent:
type: warning
message: Database backup add-on is already installed on ${env.name}. Backup addon installation is not possible.
installRestic:
- cmd[cp]:
user: root
commands:
- 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/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
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/backup_media.sh
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/check_sched.sh
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/manage_backup_schedule.sh
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/restore_backup_direct.sh
- curl -O https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main/scripts/imports/restore_full_backup_session.sh
- 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/view_backup_sessions.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/litespeed/mb-backups/*.sh
removeScripts:
- cmd[cp]:
user: root
commands:
# Remove the crontab entry for the add-on
- (crontab -l | grep -v "${globals.scriptPath}/manage_backup_schedule.sh" | crontab -) || true
# 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
# 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