|
|
@@ -44,6 +44,10 @@ check_hestia_demo_mode
|
|
|
# Action #
|
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
+# Set notification email and subject
|
|
|
+subj="$user → backup failed"
|
|
|
+email=$(grep CONTACT "$HESTIA/data/users/$ROOT_USER/user.conf" | cut -f 2 -d \')
|
|
|
+
|
|
|
source_conf $HESTIA/conf/restic.conf
|
|
|
|
|
|
if [ ! -f "$USER_DATA/restic.conf" ]; then
|
|
|
@@ -54,11 +58,24 @@ if [ ! -f "$USER_DATA/restic.conf" ]; then
|
|
|
if [ $? -ne 0 ]; then
|
|
|
check_result $E_CONNECT "Unable to create restic repo"
|
|
|
fi
|
|
|
+else
|
|
|
+ # Check if repo exists and is accessible with restic key
|
|
|
+ restic --repo "$REPO$user" --password-file $USER_DATA/restic.conf --json dump $snapshot /home/$user/backup/backup.conf > /home/$user/tmp/backup.conf
|
|
|
+ if [ $? -ne 0 ]; then
|
|
|
+ # Send an email
|
|
|
+ echo "Unable to open restic backup. It might not exists or key is incorrect" | $SENDMAIL -s "$subj" "$email" "yes"
|
|
|
+ check_result $E_CONNECT "Unable to access restic repo"
|
|
|
+ fi
|
|
|
+ rm /home/$user/tmp/backup.conf
|
|
|
fi
|
|
|
|
|
|
# create backup of the user.conf an database
|
|
|
$BIN/v-backup-user-config $user
|
|
|
restic --repo "$REPO$user" --password-file $USER_DATA/restic.conf backup /home/$user
|
|
|
+if [ $? -ne 0 ]; then
|
|
|
+ echo "Unable to create the backup" | $SENDMAIL -s "$subj" "$email" "yes"
|
|
|
+ check_result $E_BACKUP "Unable to backup user"
|
|
|
+fi
|
|
|
|
|
|
if [[ -n "$SNAPSHOTS" && "$SNAPSHOTS" -ge 0 ]]; then
|
|
|
restic_prune="$restic_prune --keep-last $SNAPSHOTS"
|