Created
February 7, 2018 21:15
-
-
Save nmukerje/aa1e85d6eb39d1b57d483606cf3e91d5 to your computer and use it in GitHub Desktop.
Syncs files from EC2 to S3.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BUCKET='<bucket>/sqoop/' | |
function upload() { | |
local path=$1 | |
local file=$2 | |
echo $path$file | |
aws s3 cp $path$file s3://$BUCKET$file & | |
} | |
inotifywait -q -e close_write /tmp/logs/sqoop/ -m | | |
while read action_dir event_list action_file; do | |
if [ -f "$action_dir$action_file" ]; then # only process a file, not a directory | |
case "${event_list}" in | |
CLOSE_WRITE* ) | |
upload "$action_dir" "$action_file" > /dev/null 2>&1 | |
;; | |
esac | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment