Exporting Data from Countly


Use cases to Export Data

In some cases, you may find that you need to export data from Countly. This can happen in one of two cases:

  1. Archiving older data and keeping short-term data in Countly for faster server experience or reducing server costs, etc.
  2. Putting data that Countly collects in some data lake, which combines data from multiple other platforms so data scientists can connect all the data in one place

This article talks about how you can undertake such an export.

With DB Viewer

Before we dive into the DB Viewer API, please note that there is also a UI for DB Viewer in the Countly dashboard, which allows easy data export of specific collections and queries in JSON, CSV, and Excel formats.

Getting Information About All Apps

Getting User Information About a Specific App

Getting All Event Data

Without DB Viewer

Directly from MongoDB

You can also take a direct and complete data dump from MongoDB using MongoDB tools.

Using the mongodump (https://docs.mongodb.com/database-tools/mongodump/) command to dump the whole database in unreadable BSON format and then restore it using the mongorestore(https://docs.mongodb.com/database-tools/mongorestore/https://docs.mongodb.com/database-tools/mongorestore/) command.

Or alternatively, you can use mongoexport (https://docs.mongodb.com/database-tools/mongoexport/) which can also export specific collections from specific databases (or even results of queries) in JSON or CSV formats, which can be imported respectively using the mongoimport (https://docs.mongodb.com/database-tools/mongoimport/) command.

Using the Data Migration Plugin

Countly-hosted clients do not have direct access to their MongoDB, impending them from running commands like mongodump. Therefore, using the Data Migration plugin will allow Countly-hosted clients to complete the DB export. You can find more information in the Data Migration documentation.

Incremental Exports

There might be cases when you need to do incremental backups for the new data since the last backup. For these cases, it is possible to use the Data Migration, but it is not recommended because it cannot have multiple migration exports for the same app. Since Data Migration assists for exports/imports between different servers, every time you do an incremental backup, you will need to find a way to store them in a different server. 

For incremental exports, we suggest using database snapshots, which will also make the process faster.

Looking for help?