wosiu

bigmove.sh

Feb 15th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.67 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. src=`hdfs dfs -ls /data/logs-gobblin-tmp/ | tr -s ' ' | cut -d' ' -f8 |  tail -n +2 | head -n 1`
  4.  
  5. while read -r src_path
  6. do
  7.     TOPIC=`echo $src_path | sed 's/\/data\/\<logs-gobblin-tmp\>\///'`
  8.     CAMUS="/data/logs/${TOPIC}/2017/02"
  9.     GOBBLIN="${src_path}/2017/02"
  10.     CAMUS_DAY=$CAMUS/15
  11.     GOBBLIN_DAY=$GOBBLIN/15
  12.     TMP=/tmp/camus_backup/$TOPIC
  13.     echo "Creating tmp $TMP"
  14.     hdfs dfs -mkdir -p $TMP
  15.     echo "Moving $TOPIC from $CAMUS_DAY to $TMP/"
  16.     hdfs dfs -mv $CAMUS_DAY $TMP/
  17.     echo "Moved out $TOPIC from camus. Moving $GOBBLIN_DAY to $CAMUS/"
  18.     hdfs dfs -mv $GOBBLIN_DAY $CAMUS/
  19.     echo "Finished $TOPIC"
  20.  
  21. done <<< "$src"
Advertisement
Add Comment
Please, Sign In to add comment