Skip to content

Instantly share code, notes, and snippets.

@rankun203
Last active December 26, 2017 09:37
Show Gist options
  • Save rankun203/14d817c21c7cd5fd39a2b1617b0215bc to your computer and use it in GitHub Desktop.
Save rankun203/14d817c21c7cd5fd39a2b1617b0215bc to your computer and use it in GitHub Desktop.
Dump Rackspace Cloud Files Container
#!/usr/bin/env bash
# Usage:
# ./download-file.sh <CONTAINER_NAME> <FILE_PATH>
readonly CONTAINER="$1"
readonly FILE_PATH="$2"
readonly FILE_FOLDER=`dirname $FILE_PATH`
readonly IGNORED_FILES="lodestreams-docs/logs"
if [ "${FILE_PATH/$IGNORED_FILES}" = "$FILE_PATH" ] ; then
mkdir -p "$FILE_FOLDER"
echo Downloading "$FILE_PATH" from "$CONTAINER"
rack files object download --container $1 --name $FILE_PATH > $FILE_PATH
else
echo Ignore $FILE_PATH
fi
# Dump container
# Usage:
# ./dump-container.sh <CONTAINER_NAME>
if [[ $# -eq 0 ]] ; then
echo 'Try something like:'
echo './dump-container.sh CONTAINER'
exit 0
fi
readonly CONTAINER="$1"
readonly CURRENT_PATH="`pwd`"
readonly THREADS_N=1
mkdir -p files && cd files
rack files object list --container "$CONTAINER" | sed 1d | awk '{print $1}' | xargs -n 1 -P $THREADS_N $CURRENT_PATH/download-file.sh "$CONTAINER"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment