Update logging
parent
6a19fda7f5
commit
ac5187845d
|
@ -29,9 +29,9 @@ function update_restic(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_backup_repo() {
|
function check_backup_repo() {
|
||||||
local backup_repo_path="/mnt/backups/"
|
local backup_repo_path="/mnt/backups/${ENV_NAME}"
|
||||||
local password_file="/etc/restic-password"
|
local password_file="/etc/restic-password"
|
||||||
local backup_log_file="/var/log/backup_addon.log" # Set the log file path
|
local backup_log_file="/var/log/backup_addon.log"
|
||||||
|
|
||||||
# Ensure the backup repository directory exists
|
# Ensure the backup repository directory exists
|
||||||
[ -d "${backup_repo_path}" ] || mkdir -p "${backup_repo_path}"
|
[ -d "${backup_repo_path}" ] || mkdir -p "${backup_repo_path}"
|
||||||
|
@ -48,10 +48,16 @@ function check_backup_repo() {
|
||||||
export RESTIC_REPOSITORY="$backup_repo_path"
|
export RESTIC_REPOSITORY="$backup_repo_path"
|
||||||
export FILES_COUNT=$(find "${backup_repo_path}" -mindepth 1 | wc -l)
|
export FILES_COUNT=$(find "${backup_repo_path}" -mindepth 1 | wc -l)
|
||||||
|
|
||||||
# Check repository integrity if files exist; initialize otherwise
|
# Check if the repository is accessible with the current password
|
||||||
if [ "${FILES_COUNT}" -gt 0 ]; then
|
if [ "${FILES_COUNT}" -gt 0 ]; then
|
||||||
echo "$(date) ${ENV_NAME} Checking the backup repository integrity and consistency" | tee -a "${backup_log_file}"
|
echo "$(date) ${ENV_NAME} Checking the backup repository integrity and consistency" | tee -a "${backup_log_file}"
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
# 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,8 +76,6 @@ 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