2f3af1ab4db99c9f445cfd88f1ccc2145cae89d2

Author
zertrin <zrk951@gmail.com>
Committer
zertrin <zrk951@gmail.com>
Date

Message

Merge pull request #40 from brki/allow-s3-scheme-when-getting-remote-size

Let s3cmd have the correct bucket name when using s3 scheme

Diff

 1diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example
 2index 0d5fb37c09ce4302310d3c91b32f4d2545c99886..cb09289031d1902ba0a2657950828a68df49fc7d 100644
 3--- a/duplicity-backup.conf.example
 4+++ b/duplicity-backup.conf.example
 5@@ -90,8 +90,12 @@ ROOT="/home"
 6 # for you).  If you don't want to use Amazon S3, you can backup
 7 # to a file or any of duplicity's supported outputs.
 8 #
 9-# NOTE: You do need to keep the "s3+http://<your location>/" format
10-# even though duplicity supports "s3://<your location>/".
11+# The s3+http scheme uses the default aws s3 hostname.
12+# Use s3://host/bucket/[backup-folder/] if you want to specify the host name.
13+# If using the s3://... scheme and you have s3cmd installed, be sure to change
14+# 's3.amazonaws.com' to the appropriate host in your .s3cfg file so that the
15+# remote file size check will work.
16+#DEST="s3://host/backup-bucket/backup-folder/"
17 DEST="s3+http://backup-bucket/backup-folder/"
18 # Other possible locations
19 #DEST="ftp://user[:password]@other.host[:port]/some_dir"
20diff --git a/duplicity-backup.sh b/duplicity-backup.sh
21index 992e9bf8192464699d7b4d6aea2eab7ef1aeba46..3fe3bbf5ace0e2db7f1837ac43eef21738aeeee9 100755
22--- a/duplicity-backup.sh
23+++ b/duplicity-backup.sh
24@@ -338,6 +338,11 @@ get_remote_file_size()
25     "s3")
26       if $S3CMD_AVAIL ; then
27           TMPDEST=$(echo ${DEST} | cut -c 11-)
28+          dest_scheme=$(echo ${DEST} | cut -f -1 -d :)
29+          if [ "$dest_scheme" = "s3" ]; then
30+              # Strip off the host name, too.
31+              TMPDEST=`echo $TMPDEST | cut -f 2- -d /`
32+          fi
33           SIZE=`${S3CMD} du -H s3://${TMPDEST} | awk '{print $1}'`
34       else
35           SIZE="s3cmd not installed."