Updated password checks and reinitiate restic

main
Anthony 2024-11-13 01:23:39 +08:00
parent ac5187845d
commit 2a3c7341f0
1 changed files with 17 additions and 14 deletions

View File

@ -54,10 +54,11 @@ function check_backup_repo() {
if ! GOGC=20 restic -r "${backup_repo_path}" snapshots > /dev/null 2>&1; then if ! GOGC=20 restic -r "${backup_repo_path}" snapshots > /dev/null 2>&1; then
echo "$(date) ${ENV_NAME} ERROR: Repository exists but password does not match." | tee -a "${backup_log_file}" echo "$(date) ${ENV_NAME} ERROR: Repository exists but password does not match." | tee -a "${backup_log_file}"
echo "Please reinitialize the repository manually or adjust the password file." | tee -a "${backup_log_file}" echo "$(date) Reinitializing the repository with a new password." | tee -a "${backup_log_file}"
exit 1 rm -rf "${backup_repo_path}"/*
fi GOGC=20 restic init -r "${backup_repo_path}"
echo "$(date) Repository reinitialized with a new password." | tee -a "${backup_log_file}"
else
# Remove stale lock if exists # Remove stale lock if exists
if [[ $(ls -A "${backup_repo_path}/locks") ]]; then if [[ $(ls -A "${backup_repo_path}/locks") ]]; then
echo "$(date) ${ENV_NAME} Backup repository has a stale lock, removing" | tee -a "${backup_log_file}" echo "$(date) ${ENV_NAME} Backup repository has a stale lock, removing" | tee -a "${backup_log_file}"
@ -70,12 +71,14 @@ function check_backup_repo() {
echo "Backup repository integrity check failed." | tee -a "${backup_log_file}" echo "Backup repository integrity check failed." | tee -a "${backup_log_file}"
exit 1 exit 1
fi fi
fi
else else
echo "$(date) ${ENV_NAME} Initializing new backup repository" | tee -a "${backup_log_file}" echo "$(date) ${ENV_NAME} Initializing new backup repository" | tee -a "${backup_log_file}"
GOGC=20 restic init -r "${backup_repo_path}" GOGC=20 restic init -r "${backup_repo_path}"
fi fi
} }
function sendEmailNotification() { function sendEmailNotification() {
if [ -e "/usr/lib/jelastic/modules/api.module" ]; then if [ -e "/usr/lib/jelastic/modules/api.module" ]; then
[ -e "/var/run/jem.pid" ] && return 0; [ -e "/var/run/jem.pid" ] && return 0;