Skip to content

Instantly share code, notes, and snippets.

@aledbf
Last active August 29, 2015 14:12
Show Gist options
  • Save aledbf/2eacee17587b212746dd to your computer and use it in GitHub Desktop.
Save aledbf/2eacee17587b212746dd to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#"Installing s3cmd deis fork"
#pip install git+https://github.com/deis/s3cmd
ETCD_HOST=$1
BACKUP_DIRECTORY=$2
ACCESS_KEY=`etcdctl -C $ETCD_HOST:4001 get /deis/store/gateway/accessKey`
SECRET_KEY=`etcdctl -C $ETCD_HOST:4001 get /deis/store/gateway/secretKey`
template=$(cat <<EOF
[default]
access_key = #ACCESS_KEY#
bucket_location = US
default_mime_type = binary/octet-stream
delete_removed = False
dry_run = False
encoding = UTF-8
encrypt = False
follow_symlinks = False
get_continue = False
gpg_command = None
guess_mime_type = True
host_base = deis-store.local3.deisapp.com
host_bucket = deis-store.local3.deisapp.com/%(bucket)
human_readable_sizes = True
list_md5 = False
log_target_prefix =
preserve_attrs = True
progress_meter = True
recursive = False
recv_chunk = 4096
secret_key = #SECRET_KEY#
send_chunk = 4096
skip_existing = False
socket_timeout = 300
urlencoding_mode = normal
use_https = False
use_path_mode = True
EOF
)
CONFIG_FILE=`uuidgen`
echo "${template}" | sed -e "s/#ACCESS_KEY#/$ACCESS_KEY/g" | sed -e "s%#SECRET_KEY#%$SECRET_KEY%g" > /tmp/${CONFIG_FILE}
echo "Adding required hostname in /etc/hosts"
echo "$ETCD_HOST deis-store.local3.deisapp.com" >> /etc/hosts
echo "Dumping deis S3 content in directory $BACKUP_DIRECTORY"
s3cmd -c /tmp/${CONFIG_FILE} sync s3://db_wal $BACKUP_DIRECTORY
s3cmd -c /tmp/${CONFIG_FILE} sync s3://registry $BACKUP_DIRECTORY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment