-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbackup-db.sh
executable file
·33 lines (31 loc) · 1004 Bytes
/
backup-db.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
set -e
function putS3
{
path=$1
file=$2
aws_path=$3
bucket='twig-backups'
date=$(date +"%a, %d %b %Y %T %z")
acl="x-amz-acl:public-read"
content_type='application/x-compressed-tar'
string="PUT\n\n$content_type\n$date\n$acl\n/$bucket$aws_path$file"
signature=$(echo -en "${string}" | openssl sha1 -hmac "${AWS_SECRET_KEY}" -binary | base64)
echo "Uploading $file"
curl -f -X PUT -T "$path/$file" \
-H "Host: $bucket.s3.amazonaws.com" \
-H "Date: $date" \
-H "Content-Type: $content_type" \
-H "$acl" \
-H "Authorization: AWS ${AWS_ACCESS_KEY}:$signature" \
"https://$bucket.s3.amazonaws.com$aws_path$file"
}
scp -rp [email protected]:/usr/local/var/lib/couchdb ./backups
aws s3 sync ./backups/ s3://twig-backups --region us-west-2 --delete
#tar cvfz backups.tgz backups
rm -rf ./backups
#putS3 . backups.tgz "/"
# aws s3 cp ./backups s3://twig-backups --recursive
#for file in ./backups/*; do
# putS3 ./backups/ "${file##*/}" "/"
#done
#rm backups.tgz