1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/restic_ynh.git synced 2024-09-03 20:16:22 +02:00

feat: fail backup if check is not okay

This commit is contained in:
Lionel Coupouchetty-Ramouchetty 2020-02-25 22:07:47 +01:00
parent 11104e1af9
commit 210a6df836

View file

@ -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
}