Updated password checks and reinitiate restic
parent
ac5187845d
commit
2a3c7341f0
|
@ -54,21 +54,23 @@ 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
|
||||||
|
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
|
# Run the repository check command
|
||||||
if [[ $(ls -A "${backup_repo_path}/locks") ]]; then
|
if ! GOGC=20 restic -q -r "${backup_repo_path}" check --read-data-subset=5%; then
|
||||||
echo "$(date) ${ENV_NAME} Backup repository has a stale lock, removing" | tee -a "${backup_log_file}"
|
echo "Backup repository integrity check failed." | tee -a "${backup_log_file}"
|
||||||
GOGC=20 restic -r "${backup_repo_path}" unlock
|
exit 1
|
||||||
sendEmailNotification
|
fi
|
||||||
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
|
|
||||||
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}"
|
||||||
|
@ -76,6 +78,7 @@ function check_backup_repo() {
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue