Skip to content

Commit

Permalink
[scripts] export shellcheck fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ar2rsawseen committed Nov 23, 2021
1 parent 46d436d commit a4e84fc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions bin/scripts/export-data/1_full_export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ fi

tmp_file="fadlfhsdofheinwvw.js"
echo "print('_ ' + db.getCollectionNames())" > $tmp_file
cols=`mongo "${connection_string}/${db}" $tmp_file | grep '_' | awk '{print $2}' | tr ',' ' '`
cols=$(mongo "${connection_string}/${db}" $tmp_file | grep '_' | awk '{print $2}' | tr ',' ' ')
for c in $cols
do
mongoexport --uri="${connection_string}" -d $db -c $c -o "$out_dir/${db}_${c}.json"
mongoexport --uri="${connection_string}" -d "$db" -c "$c" -o "$out_dir/${db}_${c}.json"
done
rm $tmp_file
8 changes: 4 additions & 4 deletions bin/scripts/export-data/2_full_export_specific_collections.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ fi

tmp_file="fadlfhsdofheinwvw.js"
echo "print('_ ' + db.getCollectionNames().filter(function(c){return c.indexOf(\"${prefix}\") === 0}))" > $tmp_file
cols=`mongo "${connection_string}/${db}" $tmp_file | grep '_' | awk '{print $2}' | tr ',' ' '`
cols=$(mongo "${connection_string}/${db}" $tmp_file | grep '_' | awk '{print $2}' | tr ',' ' ')
for c in $cols
do
mongoexport --uri="${connection_string}" -d $db -c $c -o "$out_dir/${db}_${c}.json"
mongoexport --uri="${connection_string}" -d "$db" -c "$c" -o "$out_dir/${db}_${c}.json"
done
rm $tmp_file

Expand All @@ -47,9 +47,9 @@ fi

tmp_file="fadlfhsdofheinwvw.js"
echo "print('_ ' + db.getCollectionNames().filter(function(c){return c.indexOf(\"${prefix}\") === 0}))" > $tmp_file
cols=`mongo "${connection_string}/${db}" $tmp_file | grep '_' | awk '{print $2}' | tr ',' ' '`
cols=$(mongo "${connection_string}/${db}" $tmp_file | grep '_' | awk '{print $2}' | tr ',' ' ')
for c in $cols
do
mongoexport --uri="${connection_string}" -d $db -c $c -o "$out_dir/${db}_${c}.json"
mongoexport --uri="${connection_string}" -d "$db" -c "$c" -o "$out_dir/${db}_${c}.json"
done
rm $tmp_file
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ seconds=86400


timestamp="$(date +"%s")"
start_timestamp=$((${timestamp}-${seconds}))
start_timestamp=$((timestamp-seconds))
start_date="$(date -u +'%Y-%m-%dT%H:%M:%S+0000' -d @${start_timestamp})"
prefix="app_users"
db="countly"
Expand All @@ -30,10 +30,10 @@ fi

tmp_file="fadlfhsdofheinwvw.js"
echo "print('_ ' + db.getCollectionNames().filter(function(c){return c.indexOf(\"${prefix}\") === 0}))" > $tmp_file
cols=`mongo "${connection_string}/${db}" $tmp_file | grep '_' | awk '{print $2}' | tr ',' ' '`
cols=$(mongo "${connection_string}/${db}" $tmp_file | grep '_' | awk '{print $2}' | tr ',' ' ')
for c in $cols
do
mongoexport --uri="${connection_string}" -d $db -c $c -o "$out_dir/${db}_${c}.json" --query "{\"last_sync\":{\"\$gte\":${start_timestamp}}}"
mongoexport --uri="${connection_string}" -d "$db" -c "$c" -o "$out_dir/${db}_${c}.json" --query "{\"last_sync\":{\"\$gte\":${start_timestamp}}}"
done
rm $tmp_file

Expand All @@ -50,9 +50,9 @@ fi

tmp_file="fadlfhsdofheinwvw.js"
echo "print('_ ' + db.getCollectionNames().filter(function(c){return c.indexOf(\"${prefix}\") === 0}))" > $tmp_file
cols=`mongo "${connection_string}/${db}" $tmp_file | grep '_' | awk '{print $2}' | tr ',' ' '`
cols=$(mongo "${connection_string}/${db}" $tmp_file | grep '_' | awk '{print $2}' | tr ',' ' ')
for c in $cols
do
mongoexport --uri="${connection_string}" -d $db -c $c -o "$out_dir/${db}_${c}.json" --query "{\"cd\":{\"\$gte\":{\"\$date\": \"${start_date}\"}}}"
mongoexport --uri="${connection_string}" -d "$db" -c "$c" -o "$out_dir/${db}_${c}.json" --query "{\"cd\":{\"\$gte\":{\"\$date\": \"${start_date}\"}}}"
done
rm $tmp_file
4 changes: 2 additions & 2 deletions bin/scripts/export-data/4_create_incremental_indexes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ prefix="app_users"
db="countly"
tmp_file="fadlfhsdofheinwvw.js"
echo "db.getCollectionNames().forEach(function(c){if(c.indexOf(\"${prefix}\") === 0){db[c].createIndex({last_sync: -1},{background: true})}})" > $tmp_file
cols=`mongo "${connection_string}/${db}" $tmp_file`
mongo "${connection_string}/${db}" $tmp_file
rm $tmp_file


prefix="drill_events"
db="countly_drill"
tmp_file="fadlfhsdofheinwvw.js"
echo "db.getCollectionNames().forEach(function(c){if(c.indexOf(\"${prefix}\") === 0){db[c].createIndex({cd: -1},{background: true})}})" > $tmp_file
cols=`mongo "${connection_string}/${db}" $tmp_file`
mongo "${connection_string}/${db}" $tmp_file
rm $tmp_file

0 comments on commit a4e84fc

Please sign in to comment.