Skip to content

Instantly share code, notes, and snippets.

@elijahcruz12
Created December 4, 2021 18:25
Show Gist options
  • Save elijahcruz12/7bcbaa1b8ad01fdd0ea45ee563086178 to your computer and use it in GitHub Desktop.
Save elijahcruz12/7bcbaa1b8ad01fdd0ea45ee563086178 to your computer and use it in GitHub Desktop.
path=$1 # the path of the directory where the files and directories that need to be copied are located
s3Dir=$2 # the s3 bucket path that must exist.
for entry in "$path"/*; do
name=`echo $entry | sed 's/.*\///'` # getting the name of the file or directory
if [[ -d $entry ]]; then # if it is a directory
aws s3 cp --endpoint=<digitaloceanendpoint> --recursive "$name" "$s3Dir/$name/"
else # if it is a file
aws s3 cp "$name" "$s3Dir/"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment