Last active
February 16, 2018 21:27
-
-
Save prenagha/f11e0b800d7f1a5733dab1289febad51 to your computer and use it in GitHub Desktop.
Arq Backup Complete Marker
This file contains 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 | |
# | |
# Use with Arq Backup www.arqbackup.com | |
# To write a backup complete marker file to Amazon AWS S3 | |
# Set as backup complete script in Arq settings for the backup destination | |
# See related script that checks these files arq-check.sh: | |
# https://gist.github.com/prenagha/c5d6c2ebf3de0a4f61afdf3610e57363 | |
# | |
arg=$1 | |
if [ -z "${arg}" ] | |
then | |
arg=main | |
fi | |
backupSet="`/bin/hostname -s`.`/usr/bin/whoami`.${arg}" | |
file=${backupSet}.txt | |
tmp=/tmp/arq-${file} | |
bucket=xxxxxx | |
resource="/${bucket}/${file}" | |
contentType="text/plain" | |
dateValue=`/bin/date "+%a, %d %b %Y %H:%M:%S %z"` | |
/bin/date +%s > ${tmp} | |
echo "${dateValue}" >> ${tmp} | |
/bin/hostname >> ${tmp} | |
/usr/bin/whoami >> ${tmp} | |
echo "${arg}" >> ${tmp} | |
echo "Arq `/usr/bin/defaults read /Applications/Arq.app/Contents/Info CFBundleVersion`" >> ${tmp} | |
/usr/bin/uname -a >> ${tmp} | |
stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}" | |
s3Key=xxxxxx | |
s3Secret="xxxxxx" | |
signature=`echo -en ${stringToSign} | /usr/bin/openssl sha1 -hmac ${s3Secret} -binary | /usr/bin/base64` | |
/usr/bin/curl -X PUT -T "${tmp}" \ | |
-H "Host: ${bucket}.s3.amazonaws.com" \ | |
-H "Date: ${dateValue}" \ | |
-H "Content-Type: ${contentType}" \ | |
-H "Authorization: AWS ${s3Key}:${signature}" \ | |
https://${bucket}.s3.amazonaws.com/${file} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment