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,21 +54,23 @@ function check_backup_repo() {
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 "Please reinitialize the repository manually or adjust the password file." | tee -a "${backup_log_file}"
exit 1
fi
echo "$(date) Reinitializing the repository with a new password." | tee -a "${backup_log_file}"
rm -rf "${backup_repo_path}"/*
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
if [[ $(ls -A "${backup_repo_path}/locks") ]]; then
echo "$(date) ${ENV_NAME} Backup repository has a stale lock, removing" | tee -a "${backup_log_file}"
GOGC=20 restic -r "${backup_repo_path}" unlock
sendEmailNotification
fi
# Remove stale lock if exists
if [[ $(ls -A "${backup_repo_path}/locks") ]]; then
echo "$(date) ${ENV_NAME} Backup repository has a stale lock, removing" | tee -a "${backup_log_file}"
GOGC=20 restic -r "${backup_repo_path}" unlock
sendEmailNotification
fi
# Run the repository check command
if ! GOGC=20 restic -q -r "${backup_repo_path}" check --read-data-subset=5%; then
echo "Backup repository integrity check failed." | tee -a "${backup_log_file}"
exit 1
# Run the repository check command
if ! GOGC=20 restic -q -r "${backup_repo_path}" check --read-data-subset=5%; then
echo "Backup repository integrity check failed." | tee -a "${backup_log_file}"
exit 1
fi
fi
else
echo "$(date) ${ENV_NAME} Initializing new backup repository" | tee -a "${backup_log_file}"
@ -76,6 +78,7 @@ function check_backup_repo() {
fi
}
function sendEmailNotification() {
if [ -e "/usr/lib/jelastic/modules/api.module" ]; then
[ -e "/var/run/jem.pid" ] && return 0;