So I am trying to catch specific errors whilst transferring files using LFTP, but the problem is, I am unable to catch them due to calling the <<EOF
to allow interfacing with the interactive shell.
The code I am using is as follows:
#Start backup procedure
lftp<<EOF
open ftps://$HOST || bye && #SEND MAIL CANNOT CONNECT TO SERVER (ERROR)
login $USER $PASSWORD || #SEND MAIL AUTH FAILURE (ERROR)
#Remove existing backups on FTP server
glob -a rm -r ./* || bye && #SEND MAIL FAILED (WARNING) TO REMOVE PREVIOUS BACKUPS
#Upload new backup to FTP server
lcd /var/opt/gitlab/backups
mput *.tar || bye && #SEND EMAIL (ERROR) FAILED TO UPLOAD FILES
bye
EOF
Obviously when bye is called the interactive session is closed, but nothing gets executed after the &&.
Anyone have any idea on how to do specific error catching like this?