Skip to content

Commit

Permalink
Merge pull request nightscout#1 from tzachi-dar/vps-1
Browse files Browse the repository at this point in the history
A script for cloning old nightscout to current db.
  • Loading branch information
jamorham authored Sep 14, 2022
2 parents 3c4178c + 4254bf5 commit 2817e8a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions clone_nightscout.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2817e8a

Please sign in to comment.