LFTP is the "Sophisticated File Transfer Program". It is available on Linux and MacOS.
Let LFTP remove files from the target that are not present in the source
--delete
Let LFTP remove the source files after the command is finished
--Remove-source-dirs --Remove-source-files
Example LFTP command to mirror from local source to remote target
lftp sftp://$(FTP_USER)@$(FTP_HOST) -e "mirror --verbose=3 --delete -R $(OUTPUTDIR) $(FTP_TARGET_DIR) ; quit"
This call will pause to ask for the password.