Skip to content

Instantly share code, notes, and snippets.

@sunny0425
Last active December 21, 2015 02:49
Show Gist options
  • Save sunny0425/6237820 to your computer and use it in GitHub Desktop.
Save sunny0425/6237820 to your computer and use it in GitHub Desktop.
#!/bin/bash
db=$1
uploads=$(dirname $0)/../public/uploads
if [ ! -d $uploads ]; then
echo "Error: directory 'public/uploads' does not exist"
exit 1
fi
if [ -z $db ]; then
echo "usage: $0 [dbname]"
exit 1
fi
cd $uploads
pwd
for file in $(mongofiles list -d $db | awk '{print $1}'); do
# use [[ for bash, instead use [ for sh
if [[ ! -f $file ]]; then
mkdir -p $(dirname $file)
mongofiles -d $db get $file
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment