Created
August 13, 2021 18:04
-
-
Save SigmaX/e511da7fbb7b0bf1c016e1dddc080f83 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export B2_ACCOUNT_ID=<your keyID here> | |
export B2_ACCOUNT_KEY=<your key here> | |
export RESTIC_PASSWORD=<your restic repository password here> | |
command1="restic -r b2:mybucket-desktop-backups:alfred/ backup /home/eric/Documents/ 2>&1" | |
output1=$(eval "${command1}") | |
result1=$? | |
command2="restic -r b2:mybucket-desktop-backups:alfred/ backup /home/eric/repos/ 2>&1" | |
output2=$(eval "${command2}") | |
result2=$? | |
message=" | |
----------Alfred Backup Report---------- | |
$(date) | |
" | |
if [[ $result1 != 0 ]] || [[ $result2 != 0 ]]; then | |
message="${message} | |
---------------------------------------- | |
BACKUP FAILED!! See output below. | |
---------------------------------------- | |
" | |
subject="Backup FAILED---$(date)" | |
else | |
message="${message} | |
---------------------------------------- | |
Backup SUCCEEDED. | |
---------------------------------------- | |
" | |
subject="Backup successful---$(date)" | |
fi | |
message="${message} | |
\$ ${command1} | |
${output1} | |
\$ ${command2} | |
${output2} | |
---------------------------------------- | |
Snapshot history: | |
---------------------------------------- | |
$(restic -r b2:mybucket-desktop-backups:alfred/ snapshots) | |
" | |
echo "Subject: ${subject}" | |
echo "Message: ${message}" | |
echo "${message}" | mailx --subject "${subject}" [email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment