+11
-6
@@ -91,13 +91,20 @@ function backup_package() {
|
|||||||
function upload() {
|
function upload() {
|
||||||
color blue "upload backup file to storage system"
|
color blue "upload backup file to storage system"
|
||||||
|
|
||||||
|
# upload file not exist
|
||||||
|
if [[ ! -f ${UPLOAD_FILE} ]]; then
|
||||||
|
color red "upload file not found"
|
||||||
|
|
||||||
|
send_mail_content "FALSE" "File upload failed at $(date +"%Y-%m-%d %H:%M:%S"). Reason: Upload file not found."
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
rclone copy ${UPLOAD_FILE} ${RCLONE_REMOTE}
|
rclone copy ${UPLOAD_FILE} ${RCLONE_REMOTE}
|
||||||
if [[ $? != 0 ]]; then
|
if [[ $? != 0 ]]; then
|
||||||
color red "upload failed"
|
color red "upload failed"
|
||||||
|
|
||||||
if [[ "${MAIL_SMTP_ENABLE}" == "TRUE" && "${MAIL_WHEN_FAILURE}" == "TRUE" ]]; then
|
send_mail_content "FALSE" "File upload failed at $(date +"%Y-%m-%d %H:%M:%S")."
|
||||||
send_mail "BitwardenRS Backup Failed" "File upload failed at $(date +"%Y-%m-%d %H:%M:%S")."
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -133,8 +140,6 @@ upload
|
|||||||
clear_dir
|
clear_dir
|
||||||
clear_history
|
clear_history
|
||||||
|
|
||||||
if [[ "${MAIL_SMTP_ENABLE}" == "TRUE" && "${MAIL_WHEN_SUCCESS}" == "TRUE" ]]; then
|
send_mail_content "TRUE" "The file was successfully uploaded at $(date +"%Y-%m-%d %H:%M:%S")."
|
||||||
send_mail "BitwardenRS Backup Success" "The file was successfully uploaded at $(date +"%Y-%m-%d %H:%M:%S")."
|
|
||||||
fi
|
|
||||||
|
|
||||||
color none ""
|
color none ""
|
||||||
|
|||||||
@@ -53,6 +53,28 @@ function send_mail() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# Send mail.
|
||||||
|
# Arguments:
|
||||||
|
# backup successful
|
||||||
|
# mail content
|
||||||
|
########################################
|
||||||
|
function send_mail_content() {
|
||||||
|
if [[ "${MAIL_SMTP_ENABLE}" == "FALSE" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# successful
|
||||||
|
if [[ "$1" == "TRUE" && "${MAIL_WHEN_SUCCESS}" == "TRUE" ]]; then
|
||||||
|
send_mail "BitwardenRS Backup Success" "$2"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# failed
|
||||||
|
if [[ "$1" == "FALSE" && "${MAIL_WHEN_FAILURE}" == "TRUE" ]]; then
|
||||||
|
send_mail "BitwardenRS Backup Failed" "$2"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
# Initialization environment variables.
|
# Initialization environment variables.
|
||||||
# Arguments:
|
# Arguments:
|
||||||
|
|||||||
Reference in New Issue
Block a user