more changes
parent
81c4db11a1
commit
e1bb7fced5
203
manifest.jps
203
manifest.jps
|
@ -3,7 +3,7 @@ jpsVersion: 6.1.1
|
|||
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.mightybox.io/addons/mb-backup-manager/raw/branch/main/
|
||||
baseUrl: https://deploy-proxy.mightybox.io/addons/mb-backup-manager/raw/branch/main
|
||||
|
||||
targetNodes:
|
||||
nodeType:
|
||||
|
@ -12,145 +12,8 @@ targetNodes:
|
|||
- lemp
|
||||
- llsmp
|
||||
|
||||
settings:
|
||||
main:
|
||||
fields:
|
||||
- type: radio-fieldset
|
||||
name: scheduleType
|
||||
hidden: false
|
||||
default: '1'
|
||||
values:
|
||||
- value: 1
|
||||
caption: Pre-defined
|
||||
- value: 2
|
||||
caption: Custom
|
||||
- value: 3
|
||||
caption: Manual (crontab)
|
||||
tooltip: "<span>A simple <a href=\"https://en.wikipedia.org/wiki/Cron#Overview\" target=\"_blank\"> cron-based</a>
|
||||
scheduler to automatically start the backup process based on prescribed timing
|
||||
instructions.</span><div><b>Note</b> that the required timestamps should be specified
|
||||
respectively to the UTC time zone.</div>"
|
||||
showIf:
|
||||
1:
|
||||
- name: cronTime
|
||||
caption: Backup schedule
|
||||
type: list
|
||||
editable: false
|
||||
values:
|
||||
- value: 0 * * * *
|
||||
caption: "Hourly (at minute 0)"
|
||||
- value: 0 0 * * *
|
||||
caption: "Daily (at 00:00)"
|
||||
- value: 0 0 * * 0
|
||||
caption: "Weekly (at 00:00 on Sunday)"
|
||||
- value: 0 0 1 * *
|
||||
caption: "Monthly (at 00:00 on day 1)"
|
||||
default: 0 0 * * *
|
||||
2:
|
||||
- type: string
|
||||
name: backupTime
|
||||
caption: Time
|
||||
inputType: time
|
||||
default: "09:00"
|
||||
cls: x-form-text
|
||||
width: 120
|
||||
required: true
|
||||
- caption: Days
|
||||
type: compositefield
|
||||
name: days
|
||||
defaultMargins: 0 12 0 0
|
||||
items:
|
||||
- name: sun
|
||||
value: true
|
||||
type: checkbox
|
||||
caption: Su
|
||||
- name: mon
|
||||
value: true
|
||||
type: checkbox
|
||||
caption: Mo
|
||||
- name: tue
|
||||
value: true
|
||||
type: checkbox
|
||||
caption: Tu
|
||||
- name: wed
|
||||
value: true
|
||||
type: checkbox
|
||||
caption: We
|
||||
- name: thu
|
||||
value: true
|
||||
type: checkbox
|
||||
caption: Th
|
||||
- name: fri
|
||||
value: true
|
||||
type: checkbox
|
||||
caption: Fr
|
||||
- name: sat
|
||||
value: true
|
||||
type: checkbox
|
||||
caption: Sa
|
||||
- name: "tz"
|
||||
caption: "Time Zone"
|
||||
type: "list"
|
||||
required: true
|
||||
editable: true
|
||||
forceSelection: true
|
||||
values: values
|
||||
3:
|
||||
- name: cronTime
|
||||
caption: Crontab
|
||||
type: string
|
||||
default: 0 0 * * *
|
||||
regexText: Cron syntax is incorrect!
|
||||
regex: "^(((([\\\\*]{1}){1,})|((\\\\*\\\\\\/){0,1}(([0-9\\/\\*\\-\\,]{1}){1,}|(([1-5]{1}){1}([0-9\\/\\*\\-\\,]{1}){1,}){1})))
|
||||
((([\\\\*]{1}){1,})|((\\\\*\\\\\\/){0,1}(([0-9\\/\\*\\-\\,]{1}){1,}|(([1]{1}){1}([0-9\\/\\*\\-\\,-]{1}){1,}){1}|([2]{1}){1}([0-3]{1}){1})))
|
||||
((([\\\\*]{1}){1})|((\\\\*\\\\\\/){0,1}(([1-9]{1}){1}|(([1-2]{1}){1}([0-9\\/\\*\\-\\,]{1}){1,5}){1}|([3]{1}){1}([0-1]{1}){1})))
|
||||
((([\\\\*]{1}){1})|((\\\\*\\\\\\/){0,1}(([1-9]{1}){1}|(([1-2]{1}){1}([0-9\\/\\*\\-\\,]{1}){1,}){1}|([3]{1}){1}([0-1]{1}){1}))|(jan|JAN|feb|FEB|mar|MAR|apr|APR|may|MAY|jun|JUN|jul|JUL|aug|AUG|sep|SEP|okt|OKT|nov|NOV|dec|DEC)(-?\\w+?)?)
|
||||
((([\\\\*]{1}){1})|((\\\\*\\\\\\/){0,1}(([0-7]{1,}(-?[0-7]?(,[0-7]){0,6})){1}))|((sun|SUN|mon|MON|tue|TUE|wed|WED|thu|THU|fri|FRI|sat|SAT)?(,(sun|SUN|mon|MON|tue|TUE|wed|WED|thu|THU|fri|FRI|sat|SAT)){0,6})(-?\\w+?)?))$|^(@(reboot|yearly|annualy|monthly|weekly|daily|hourly))$"
|
||||
- caption: Backup storage
|
||||
type: list
|
||||
tooltip: "The environment with backup storage to be used for backups creation. Presence of this environment is obligatory."
|
||||
name: storageName
|
||||
dependsOn: region
|
||||
required: true
|
||||
- type: spinner
|
||||
name: backupCount
|
||||
caption: Number of backups
|
||||
tooltip: "The number of newest backups to be kept during rotation."
|
||||
min: 1
|
||||
max: 30
|
||||
default: 5
|
||||
onBeforeInit: scripts/configOnBeforeInit.js
|
||||
|
||||
restore:
|
||||
fields: []
|
||||
onBeforeInit: scripts/multipleRestoreOnBeforeInit.js
|
||||
|
||||
onBeforeInit: scripts/backupOnBeforeInit.js
|
||||
|
||||
buttons:
|
||||
- caption: Backup Now
|
||||
action: backup
|
||||
loadingText: Backing up...
|
||||
confirmText: Do you want to initiate the backup process?
|
||||
successText: The backup process has been finished successfully.
|
||||
|
||||
- caption: Configure
|
||||
action: configure
|
||||
settings: main
|
||||
loadingText: Configuring...
|
||||
successText: The backup configs have been updated successfully.
|
||||
|
||||
- caption: Restore
|
||||
action: restore
|
||||
loadingText: Restoring...
|
||||
settings: restore
|
||||
successText: The backup have been successfully restored.
|
||||
title: Restore Backup
|
||||
submitButtonText: Restore
|
||||
confirmText: You are going to restore from a backup, which will override all your existing data. This action cannot be canceled or reverted. Do you want to proceed?
|
||||
|
||||
globals:
|
||||
scriptSufix: wp-backup
|
||||
scriptSufix: wpmb-backup
|
||||
|
||||
onInstall:
|
||||
- checkApplication
|
||||
|
@ -173,21 +36,9 @@ onAfterClone:
|
|||
- script: return {result:0, jps:MANIFEST};
|
||||
- install: ${response.jps}
|
||||
nodeGroup: ${targetNodes.nodeGroup:cp}
|
||||
envName: ${event.response.env.envName}
|
||||
settings:
|
||||
scheduleType: ${settings.scheduleType}
|
||||
storageName: ${settings.storageName}
|
||||
cronTime: ${settings.cronTime}
|
||||
backupTime: ${settings.backupTime}
|
||||
sun: ${settings.sun}
|
||||
mon: ${settings.mon}
|
||||
tue: ${settings.tue}
|
||||
wed: ${settings.wed}
|
||||
thu: ${settings.thu}
|
||||
fri: ${settings.fri}
|
||||
sat: ${settings.sat}
|
||||
tz: ${settings.tz}
|
||||
backupCount: ${settings.backupCount}
|
||||
cronTime: "0 * * * *"
|
||||
backupCount: "5"
|
||||
|
||||
onAfterConfirmTransfer: setSchedule
|
||||
|
||||
|
@ -230,16 +81,16 @@ actions:
|
|||
|
||||
installRestic:
|
||||
cmd [cp]: |-
|
||||
if which dnf; then
|
||||
dnf install epel-release
|
||||
dnf install restic
|
||||
if which dnf >/dev/null 2>&1; then
|
||||
dnf install -y epel-release
|
||||
dnf install -y restic
|
||||
else
|
||||
yum-config-manager --add-repo https://copr.fedorainfracloud.org/coprs/copart/restic/repo/epel-7/copart-restic-epel-7.repo
|
||||
yum-config-manager --enable copr:copr.fedorainfracloud.org:copart:restic
|
||||
yum -y install restic
|
||||
yum-config-manager --disable copr:copr.fedorainfracloud.org:copart:restic
|
||||
wget -O /etc/logrotate.d/backup-addon ${baseUrl}/scripts/backup-addon;
|
||||
fi
|
||||
fi
|
||||
user: root
|
||||
|
||||
installScript:
|
||||
|
@ -249,7 +100,7 @@ actions:
|
|||
params:
|
||||
scriptName: ${env.envName}-${globals.scriptSufix}
|
||||
baseUrl: ${baseUrl}
|
||||
cronTime: ${this.cronTime}
|
||||
cronTime: '${this.cronTime}'
|
||||
backupCount: ${this.backupCount}
|
||||
userId: ${env.uid}
|
||||
storageNodeId: ${response.storageCtid}
|
||||
|
@ -289,45 +140,11 @@ actions:
|
|||
|
||||
getStorageCtid:
|
||||
- script: scripts/getStorageCtid.js
|
||||
|
||||
convert:
|
||||
- script: |
|
||||
var resp = {result:0, onAfterReturn: {setGlobals:{cron: ""}}}, offset = java.util.TimeZone.getTimeZone("${settings.tz}").getRawOffset(),
|
||||
setGlobals = resp.onAfterReturn.setGlobals;
|
||||
|
||||
var time = "${settings.backupTime}".split(":"),
|
||||
d1 = new Date(2020, 1, 10, parseInt(time[0],10), parseInt(time[1],10)),
|
||||
d2 = new Date(d1.getTime() - offset),
|
||||
dd = d2.getDate() - d1.getDate(),
|
||||
days = getDays([${settings.sun:0}, ${settings.mon:0}, ${settings.tue:0}, ${settings.wed:0}, ${settings.thu:0}, ${settings.fri:0}, ${settings.sat:0}], dd);
|
||||
|
||||
setGlobals.cron = d2.getMinutes() + " " + d2.getHours() + " * * " + days.join(",");
|
||||
|
||||
|
||||
function getDays(settings, dd) {
|
||||
var days = [];
|
||||
for (var i = 0, n = settings.length; i < n; i++) {
|
||||
if (settings[i]) {
|
||||
var day = i + dd;
|
||||
if (day < 0) day +=7; else if (day > 6) day -=7;
|
||||
days.push(day);
|
||||
}
|
||||
}
|
||||
days.sort();
|
||||
return days;
|
||||
}
|
||||
|
||||
return resp;
|
||||
|
||||
setSchedule:
|
||||
- setGlobals:
|
||||
storageEnv: ${settings.storageName}
|
||||
- if ("${settings.scheduleType}" == 2):
|
||||
- convert
|
||||
- else:
|
||||
- setGlobals:
|
||||
cron: ${settings.cronTime}
|
||||
- installScript:
|
||||
cronTime: ${globals.cron}
|
||||
backupCount: ${settings.backupCount}
|
||||
backupCount: 5
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
/var/log/backup_addon.log {
|
||||
weekly
|
||||
rotate 52
|
||||
missingok
|
||||
notifempty
|
||||
compress
|
||||
copytruncate
|
||||
}
|
Loading…
Reference in New Issue