How to Migrate Your Parse Data to Your Own Server?

0
Shares
How to Migrate Your Parse Data to Your Own Server?
4 (80%) 1 vote

Shifting is just the begin. Parse’s hosted service will be fully retired on January 28, 2017, and thus, they have released two tools that help for transiting application from Parse to another service. As Parse will operate until January 28, 2017, developers have enough time to move 600,000 apps, built on the Parse, to other platforms.

With open source Parse Server, the Parse API can host Node.js applications from any infrastructure. Parse Server enables to run any application without major changes in the client-side code, once you have data in your own database. However, Parse will be retired, you might be thinking to migrate an Existing Parse App, there here is the process.

It is assumed that the migration guide is using Heroku and MongoLab as these services are simple to use when you are deploying and managing your own backend stack.

However, developers can choose an infrastructure provider that supports Node.js environments. Once you have completed, you will have

  •         Parse Server running on Heroku.
  •         App’s data stored in MongoDB hosted on MongoLab.
  •         No dependency on api.parse.com for the new app client.
  •         Parse Server running on your computer, allowing to develop locally.
  •         App’s client-side code updated to point to the Parse Server instance on Heroku, ready to be released.

Have a glance at a visual overview of the migration steps:

How migrate Parse DB to Self-Hosted MongoDB?

The very first step of migration data from Parse hosted application to self-hosted MongoDB. Firstly, you have to setup a MongoDB instance by making the size of Mongo at least 10X to the current amount of data storage you are using. (You can get this information from app’s Analytics overview page.)

After setting up Mongo, pay attention to the Mongo connection URL. Make use of the database migration tool for transferring your data.

Find New Dashboard: App Settings >> General >> Migrate to external database.

Just you have to ensure that the users in the connection string have admin privileges because the migration tools will set some parameters during the process automatically. With the tool, you can first take a picture of your existing data and then, transfers it to MongoDB.

After that, it will pause to enable manual verification and on another side, it will continue sync things with writes that are coming in from live app. Additionally, an application also continues to read and write from Parse hosted database.

Now, you have to connect to your Mongo instance and browse through the collections in the latest developed database. It’s time to check the collection counts and do some spot checks to ensure that data was migrated successfully.

When you get the satisfactory result, you can conclude the transfer in the migration UI and application will start using the latest MongoDB instance.

At this moment, an application is still hitting api.parse.com, however, it uses MongoDB instance. Now, you will require checking database instance by your own, including indexes maintaining and scaling up.

Note: One can skip migrating their data and test the functionality of their Parse Server hosted app with a blank database. It is recommended to migrate your data later.

How to Set Up Local Parse Server?

Go through the given instructions in the Parse Server Sample App and see step 1 to use the Mongo connection string.

Go to the Security & Keys section of App Settings and make use of the File Key, Master Key, JavaScript Key, Client Key, and dotNETKey. After that, you have to pass that into the ParseServer constructor in index.js.

Verification

You have to ensure that saving an object and retrieving it through a query works:

curl -X POST \
-H “X-Parse-Application-Id: YOUR_APP_ID” \
-H “Content-Type: application/json” \
-d ‘{“score”:1337,”playerName”:”Sean Plott”,”cheatMode”:false}’ \
http://localhost:1337/parse/classes/GameScore

curl -X GET \
-H “X-Parse-Application-Id: YOUR_APP_ID” \
-H “X-Parse-Master-Key: YOUR_APP_MASTER_KEY” \
http://localhost:1337/parse/classes/GameScore

Now, you can have a Parse Server running locally, which is associated with the data in MongoDB from step 1.

Cloud Code

It’s time to migrate an existing Cloud Code to run in Parse Server. Be ready to Copy your app’s Cloud Code to the parse-server/cloud directory and replace the example main.js. You are free to replace any relative paths like ‘cloud/…’ to ‘./cloud’.

As NativeCloud Code modules are not available in Parse Server, you should have to use a replacement

Native Cloud Code modules are not available in Parse Server, so you will need to use a replacement:

  •         App Links – no direct replacement, but easy to generate these tags on your own.
  •         Buffer – included natively with Node. It removes any requires (‘buffer’) calls.
  •         Mailgun – Use the official npm module
  •         Mandrill – Use the official npm module
  •         Moment – Use the official npm module
  •         Parse Image – it is recommended to use another image manipulation library, like the imagemagick wrapper module
  •         SendGrid – Use the official npm module
  •         Stripe – Use the official npm module
  •         Twilio – Use the official npm module
  •         Underscore – Use the official npm module

Verification

Run Parse Server and make some calls to it to see that your Cloud Code is running perfectly or not.

If you had tests setup for the Cloud Code in your Parse hosted backend, it would be great to point them to your local Parse Server and run the test suite, as it isn’t running a full node environment.  

It is recommended to exercising all the critical code paths to check functionality.

Hosting

In case, you are using Parse Hosting, you can simply migrate all these web endpoints to the same Express app, which is serving Parse Server. For e.g. You could mount Parse Server under /parse and your website at the root, like this:

var api = new ParseServer({ … });
app.use(‘/parse’, api);

// Web endpoints
app.get(‘/’, homeController.index);
app.get(‘/about’, aboutController.index);

// …

App Settings

Go through your application settings panel and ensure to understand how such settings will be stuck by moving to Parse Server.  

User Sessions

  •         Revoke session on password change – This is not yet available in Parse Server.
  •         Require revocable sessions – This is required by Parse Server.
  •         Expire inactive sessions – This is not yet available in Parse Server.

User Authentication

  •         Enable New Methods by Default – This is hardcoded as true in Parse Server.
  •         Allow username and password-based authentication – Not optional in Parse Server, accounts based on username and password are always enabled.
  •         Allow anonymous users – Currently, this is not optional in Parse Server, anonymous users are always enabled.

Social Login

  •         Allow FB auth – If a Facebook App ID is configured, this is available in Parse Server.
  •         Add a Facebook app (list of apps) – restrict to one Facebook application is not available in Parse Server.

Point Client to Local Parse Server

It is must to update an application with the latest version of the Parse SDK that will have the ability to change the server URL. The least version of iOS is 1.12, Android is 1.13.0, JS is 1.6.14 and .NET is 1.7.0.

Checkpoint: Test Your App

Your next step should test your application locally. You have to careful about Parse Server that pointing to the same Mongo instance as your live app, as you could be changing production data. At this instant, app may be totally functional. Things like objects, queries, and users will work perfectly.

Compatibility Issues

There are some areas where you can find Parse Server doesn’t provide supportability with the Parse hosted backend.

Analytics – it is recommended to send analytics to another similar service like Google Analytics and Mixpanel.

Dashboard – They don’t provide a self-hosted dashboard, however, you can write your own dashboard with the JavaScript SDK and host it yourself or else, you can manage the data directly in Mongo. It is also possible to use the Parse hosted dashboard, as it points same data in Mongo. But, this is not a long-term solution because the hosted Parse State may deviate and alter data in unpredictable ways.  

Client Class Creation – This is permissible in Parse Server.

Config – Config is not supported. However, you can create config variables in Node that can be altered and deployed. It would be forthright to develop a Node version of Parse Config with a dashboard to change these variables without a deployment.

In-App Purchase – In-app purchase for iOS verification is not supported.

Jobs – You don’t find any job functionality in Parse Server. It is recommended to port jobs (if it is scheduled) over to a self-hosted solution by using open source job queue projects, one of the popular is kue.    

Push Notifications – Parse Server doesn’t implement any push notification functionality. So, it is best to migrate to a different push provider. What you can do is export all data in your app settings and clutch the device tokens in the installation class and upload it to another push provider. You can also grab these tokens directly from your MongoDB under the installations collection. After that, you have to publish a new version of your application by replacing Parse’s push registration with the other service.

Exporting GCM Registration IDs

Sending push to Android devices is also supported by Parse via Google Cloud Messaging (GCM). By default, the GCM registration IDs are connected with Parse’s GCM sender ID that won’t work after Parse is retired.

Moreover, you have to follow below actions, if your app registers with a different GCM sender ID that will create the registration IDs in the deviceToken field exportable to other push providers:

  •         You can GCM for your Android project in the Google Developer Console. Ensure to note your project number, it should be like 123427208255. This is also known as your GCM sender ID.   
  •         Add the com.parse.push.gcm_sender_id metadata attribute for Parse registers to your app manifest so that they can push with your GCM sender ID. Android SDK 1.8.0 or higher is needed to this attribute.
  •         Now, Parse will register for GCM with both GCM sender ID and your GCM sender ID on app startup. One can use the resulting GCM registration IDs other GCM push providers.

Schema API is not supported

Session Features – the use of revocable sessions is needed by Parse Server. Follow

Parse Server requires the use of revocable sessions. If your app is still using legacy sessions, follow this migration guide. In fact, Parse server doesn’t implement an option to expire inactive sessions and to retract a session on password changes.

Social Login – Facebook and Anonymous logins are supported only.

Webhooks – Not supported

Welcome Emails and Email Verification – it’s not supported. However, you can use a beforeSave for sending emails by using Mailgun and also add logic for verification.

Set Up Parse Server on Heroku

Want to deploy the server to Heroku, follow the available instruction.

Point Client to Heroku Parse Server

Now, you have to update your client to point to the location of the API that you deployed on Heroku.

Checkpoint: Test Your App

Test your application that it uses the Heroku backend.

Publish Your App

It’s time to publish the new application that has a new backend.

In addition to, if you are looking for some replacement then here is two suggestions that might help you to migrate Parse Server to existing Database.

CloudKit can store users’ data and files and a lot of APIs to access from the cloud. CloudKit framework provided by Apple help to integrate an application with ease. Considering everything into account, CloudKie is a framework that used to replace backend servicers like file storage and server database. If you are using CloudKit, you don’t have to bother about anything, just be concentrate on an application.

Having a NoSQL data store, apigee is a useful API BaaS (Backend as a Sevice) that built on the Apache Usergrid project. API BaaS provides an Admin Portal for data management and SDKs for working with the data store in your client applications. Some recommendable features of Parse like Cloud code, Data Storage, Analytics, User Management, Push Notifications and more.

It’s blowing the issue among those people, who want to migrate Parse Data to Your Own Server. If you are one of them – We would love to hear Your migration project Idea.

This page was last edited on September 24th, 2018, at 6:57.
 
0
Shares
 

Have an App Idea?

Get your free consultation now