diff --git a/conf/backup_method.j2 b/conf/backup_method.j2 index 7719e28..cccf072 100644 --- a/conf/backup_method.j2 +++ b/conf/backup_method.j2 @@ -33,13 +33,18 @@ do_backup() { current_date=$(date +"%d_%m_%y_%H:%M") pushd $work_dir $RESTIC_COMMAND backup ./ >> $LOGFILE 2>> $ERRFILE - return_code="$?" + backup_return_code="$?" $RESTIC_COMMAND check >> $LOGFILE 2>> $ERRFILE + check_return_code="$?" popd # On ne nettoie que si la sauvegarde s'est bien passee - if [ "$return_code" -eq "0" ];then - $RESTIC_COMMAND forget --keep-daily 7 --keep-weekly 8 --keep-monthly 12 >> $LOGFILE 2>> $ERRFILE + if [ "$backup_return_code" -eq "0" ] && [ "$check_return_code" -eq 0 ];then + $RESTIC_COMMAND forget --keep-daily 7 --keep-weekly 8 --keep-monthly 12 >> $LOGFILE 2>> $ERRFILE + else + [ "$backup_return_code" -ne 0 ] && echo "Something went wrong during backup" >> $ERRFILE + [ "$check_return_code" -ne 0 ] && echo "Repository check did not return 0" >> $ERRFILE + exit 1 fi }