From 4254bf54e129fcc6569a1289a3072286e8793a37 Mon Sep 17 00:00:00 2001 From: Tzachi Dar Date: Wed, 14 Sep 2022 02:53:04 +0300 Subject: [PATCH] A script for cloning old nightscout to current db. run as ./clone_nightscout.sh https://site.herokuapp.com --- clone_nightscout.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 clone_nightscout.sh diff --git a/clone_nightscout.sh b/clone_nightscout.sh new file mode 100644 index 00000000000..82dad41e487 --- /dev/null +++ b/clone_nightscout.sh @@ -0,0 +1,17 @@ +clone_collection() { + REST_ENDPOINT=$1 + collection_name=$2 + echo $REST_ENDPOINT + if [[ $collection_name == entries ]]; then + wget $REST_ENDPOINT/api/v1/$collection_name'.json?find[date][$gte]=1662845659&count=1000000' -O $collection_name.json + else + wget $REST_ENDPOINT/api/v1/$collection_name'.json?find[created_at][$gte]=1662845659&count=1000000' -O $collection_name.json + fi + jq '.[]' $collection_name.json > $collection_name.jq.json + mongoimport --uri "mongodb://username:password@localhost:27017/Nightscout" --collection=$collection_name --file=$collection_name.jq.json + +} +for collection in entries activity devicestatus food profile treatments; +do echo "<$collection>"; +clone_collection $1 $collection +done \ No newline at end of file