Added create-backup-main-script.js
parent
290fd683af
commit
b6aab4e747
50
manifest.jps
50
manifest.jps
|
@ -13,20 +13,29 @@ targetNodes:
|
||||||
- llsmp
|
- llsmp
|
||||||
|
|
||||||
globals:
|
globals:
|
||||||
scriptSufix: wpmb-backup
|
scriptSufix: mb-backup-manager
|
||||||
|
envName: "${env.name}"
|
||||||
|
log_file: "/var/log/backup_addon.log"
|
||||||
|
|
||||||
onInstall:
|
onInstall:
|
||||||
- checkApplication
|
- checkApplication
|
||||||
- checkAddons
|
- checkAddons
|
||||||
- installRestic
|
- installRestic
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
menu:
|
menu:
|
||||||
confirmText: Backup ALL Now?
|
confirmText: Backup Core Files?
|
||||||
loadingText: Backing up ALL data on your site
|
loadingText: Backing up Core Files on your site
|
||||||
action: backupnow
|
action: backupcore
|
||||||
caption: Backup All
|
caption: Backup Core Only
|
||||||
successText: Backup All Completed Successfully
|
successText: Backup Core Files Completed Successfully
|
||||||
title: Backup All Now
|
title: Backup Core Files
|
||||||
submitButtonText: Backup Now
|
submitButtonText: Backup Now
|
||||||
|
|
||||||
onUninstall:
|
onUninstall:
|
||||||
|
@ -110,7 +119,6 @@ actions:
|
||||||
|
|
||||||
installScript:
|
installScript:
|
||||||
- removeScript
|
- removeScript
|
||||||
- getStorageCtid
|
|
||||||
- script: ${baseUrl}/scripts/create-backup-main-script.js?_r=${fn.random}
|
- script: ${baseUrl}/scripts/create-backup-main-script.js?_r=${fn.random}
|
||||||
params:
|
params:
|
||||||
scriptName: ${env.envName}-${globals.scriptSufix}
|
scriptName: ${env.envName}-${globals.scriptSufix}
|
||||||
|
@ -140,6 +148,32 @@ actions:
|
||||||
backup:
|
backup:
|
||||||
- callScript: backup
|
- callScript: backup
|
||||||
|
|
||||||
|
backupcore:
|
||||||
|
- cmd[cp]: |-
|
||||||
|
# Ensure the /mbmanager directory exists
|
||||||
|
mkdir -p /mbmanager
|
||||||
|
|
||||||
|
# Download the backup-logic.sh script if it doesn't already exist
|
||||||
|
if [ ! -f /mbmanager/backup-logic.sh ]; then
|
||||||
|
echo "Downloading backup-logic.sh script..."
|
||||||
|
wget -O /mbmanager/backup-logic.sh '${baseUrl}/scripts/backup-logic.sh' || curl -o /mbmanager/backup-logic.sh '${baseUrl}/scripts/backup-logic.sh'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make the script executable
|
||||||
|
chmod +x /mbmanager/backup-logic.sh
|
||||||
|
|
||||||
|
# Export necessary environment variables
|
||||||
|
export ENV_NAME='${globals.envName}'
|
||||||
|
export BACKUP_LOG_FILE='${globals.log_file}'
|
||||||
|
export BACKUP_TYPE='manual'
|
||||||
|
export APP_PATH='/var/www/webroot/ROOT'
|
||||||
|
export RESTIC_PASSWORD='your_restic_repository_password' # Replace with your actual password
|
||||||
|
export backupPath='/mnt/backups'
|
||||||
|
|
||||||
|
# Execute the backup_wp_core function from the script
|
||||||
|
/bin/bash /mbmanager/backup-logic.sh backup_wp_core
|
||||||
|
user: root
|
||||||
|
|
||||||
restore:
|
restore:
|
||||||
- cmd[cp]: |-
|
- cmd[cp]: |-
|
||||||
echo "${settings.backupedEnvName}" > /root/.backupedenv
|
echo "${settings.backupedEnvName}" > /root/.backupedenv
|
||||||
|
|
|
@ -4,7 +4,7 @@ var action = getParam("action", "backup"),
|
||||||
baseUrl = "${baseUrl}";
|
baseUrl = "${baseUrl}";
|
||||||
|
|
||||||
function run() {
|
function run() {
|
||||||
var BackupManager = use("scripts/mb-backup-manager.js", {
|
var BackupManager = use("scripts/backup-manager.js", {
|
||||||
session : session,
|
session : session,
|
||||||
baseUrl : baseUrl,
|
baseUrl : baseUrl,
|
||||||
uid : user.uid,
|
uid : user.uid,
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
//@auth
|
||||||
|
//@req(baseUrl, cronTime)
|
||||||
|
|
||||||
|
var scriptName = getParam("scriptName", "${env.envName}-wp-backup"),
|
||||||
|
envName = getParam("envName", "${env.envName}"),
|
||||||
|
envAppid = getParam("envAppid", "${env.appid}"),
|
||||||
|
userId = getparam("userId", ""),
|
||||||
|
backupCount = getParam("backupCount", "5");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function run() {
|
||||||
|
var BackupManager = use("scripts/backup-manager.js", {
|
||||||
|
session : session,
|
||||||
|
baseUrl : baseUrl,
|
||||||
|
uid : userId,
|
||||||
|
cronTime : cronTime,
|
||||||
|
scriptName : scriptName,
|
||||||
|
envName : envName,
|
||||||
|
envAppid : envAppid,
|
||||||
|
backupCount : backupCount
|
||||||
|
});
|
||||||
|
|
||||||
|
api.local.ReturnResult(
|
||||||
|
BackupManager.install()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function use(script, config) {
|
||||||
|
var Transport = com.hivext.api.core.utils.Transport,
|
||||||
|
url = baseUrl + "/" + script + "?_r=" + Math.random(),
|
||||||
|
body = new Transport().get(url);
|
||||||
|
return new (new Function("return " + body)())(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
run();
|
||||||
|
} catch (ex) {
|
||||||
|
var resp = {
|
||||||
|
result : com.hivext.api.Response.ERROR_UNKNOWN,
|
||||||
|
error: "Error: " + toJSON(ex)
|
||||||
|
};
|
||||||
|
|
||||||
|
api.marketplace.console.WriteLog("ERROR: " + resp);
|
||||||
|
api.local.ReturnResult(resp);
|
||||||
|
}
|
Loading…
Reference in New Issue