Fix JPS errors

main
Anthony 2024-11-13 02:21:11 +08:00
parent 301d5dceda
commit 12226390a7
2 changed files with 24 additions and 23 deletions

View File

@ -1,5 +1,5 @@
type: update
jpsVersion: 1.1
jpsVersion: 1.2
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.
@ -181,22 +181,23 @@ onAfterClone:
actions:
configureAutoBackup:
- cmd[cp]:
user: root
commands: |
if [ ! -f /etc/restic-password ]; then
echo "Error: Restic password file not found"
exit 1
fi
RESTIC_PWD=$(cat /etc/restic-password)
if [ "${settings.frequency}" = "daily" ]; then
bash ${globals.scriptPath}/manage_backup_schedule.sh add "0 ${settings.hour} * * *" "$RESTIC_PWD"
else
bash ${globals.scriptPath}/manage_backup_schedule.sh add "0 ${settings.hour} * * ${settings.dayOfWeek}" "$RESTIC_PWD"
fi
- return:
type: info
message: "${response.out}"
- cmd[cp]:
user: root
commands: |
if [ ! -f /etc/restic-password ]; then
echo "Error: Restic password file not found"
exit 1
fi
RESTIC_PWD=$(cat /etc/restic-password)
if [ "${settings.frequency}" = "daily" ]; then
cron_schedule="0 ${settings.hour} * * *"
else
cron_schedule="0 ${settings.hour} * * ${settings.dayOfWeek}"
fi
bash ${globals.scriptPath}/manage_backup_schedule.sh add "$cron_schedule" "$RESTIC_PWD"
- return:
type: info
message: "${response.out}"
removeAutoBackup:
- cmd[cp]:

View File

@ -109,8 +109,8 @@ add_update_cron_job() {
# Prepare cron command with environment variables and error handling
local CMD="RESTIC_PASSWORD=\"$restic_password\" \
LOG_FILE=\"${BACKUP_LOG_PREFIX}\$(date +\\%Y-\\%m-\\%d_\\%H-\\%M-\\%S).log\" \
$BACKUP_SCRIPT > \"\$LOG_FILE\" 2>&1 || echo \"\$(date) Backup failed\" >> \"$ACTION_LOG_FILE\""
LOG_FILE=\"${BACKUP_LOG_PREFIX}\$(date +\\%Y-\\%m-\\%d_\\%H-\\%M-\\%S).log\" \
$BACKUP_SCRIPT > \"\$LOG_FILE\" 2>&1 || echo \"\$(date) Backup failed\" >> \"$ACTION_LOG_FILE\""
# Safely update crontab
crontab -l 2>/dev/null | grep -v "$BACKUP_SCRIPT" > "$temp_crontab" || true