Skip to content
Get started
Bastionary › Knowledge base › Migration

Export your users and keep your identity data portable

By Bastionary · Migration

Migrating identity providers is not a single API call. The work gets blocked by undocumented behavior, custom claims, brittle user imports, and downstream systems that depend on provider-specific assumptions. This guide shows how to export your users and keep your identity data portable while you move to a self-hosted Bastionary deployment.

Inventory every sign-in path before touching data

Start by mapping the full surface area of your current identity stack. You need to know every place a user can authenticate and every service that trusts the resulting tokens.

  • List every client application: web apps, mobile apps, single-page apps, and machine-to-machine services.
  • Document all identity providers: social logins, enterprise SAML connections, OIDC providers, and database-backed password accounts.
  • Record every custom claim or user attribute that downstream services consume, including roles, tenant membership, seat counts, and license status.
  • Identify admin, support, and automated workflows that create or modify accounts outside the normal registration flow.

The goal is a complete dependency graph. If you skip this step, you will discover a hidden consumer of a custom claim only after users cannot log in.

Export users into a normalized format

Most providers expose a user export, but the shape is rarely what you need for a clean import. Transform the export into a schema you own before you attempt a migration.

A normalized user record should include at least the following fields:

  • external_id: the unique identifier in the source system.
  • email and email_verified: required for password resets and account recovery.
  • status: active, disabled, pending, or any custom state your system recognizes.
  • password_hash, hash_algorithm, and hash_parameters: needed if you want users to keep their passwords.
  • custom_attributes: a flat map of claims, roles, and entitlements.

Here is a small Python helper that maps a generic provider record into that normalized shape:

def map_user(record):
    attrs = {item["Name"]: item["Value"] for item in record["Attributes"]}
    return {
        "external_id": record["Username"],
        "email": attrs.get("email"),
        "email_verified": attrs.get("email_verified") == "true",
        "status": record["UserStatus"].lower(),
        "password_hash": record.get("PasswordHash"),
        "hash_algorithm": record.get("HashAlgorithm", "bcrypt"),
        "custom_attributes": attrs,
    }

Store the normalized export as newline-delimited JSON or CSV. Keep it encrypted at rest and restrict access to the migration team.

Handle password hashes and credentials safely

Password hashes are the most sensitive part of the export. If you can reuse them, users will not need to reset their passwords after cutover.

  • Determine which hashing algorithm the source provider uses. Common formats include bcrypt, PBKDF2, scrypt, and Argon2.
  • If the algorithm is supported by Bastionary, import the hash as-is and configure the verifier accordingly.
  • If the algorithm is proprietary or wrapped, import a placeholder hash and force a password reset on first login.
  • Never attempt to decrypt or downgrade hashes. If the source provider only offers encrypted hashes, request an unwrapped export or accept a reset workflow.

For social and enterprise identities, export the linked provider identifiers and any refresh tokens your application uses. OAuth tokens are often tied to the source issuer, so expect to re-link those accounts during the first post-migration login.

Validate the export before cutover

Import the normalized data into a staging Bastionary instance before you touch production. Validation should cover data integrity, authentication behavior, and audit completeness.

  1. Import a representative sample first: pick a few active accounts, disabled accounts, admin accounts, and accounts with unusual attributes.
  2. Run a batch authentication test against the staging database using known passwords and existing sessions.
  3. Verify that custom claims appear correctly in issued tokens and that downstream services still authorize users as expected.
  4. Check that timestamps, status transitions, and audit history are preserved accurately.

When validation passes, perform a dry-run import of the full dataset. Compare row counts, spot-check random users, and confirm that every user in the source export maps to exactly one record in Bastionary.

Execute the migration with a rollback path

Cutover day should be boring. If the preparation is solid, the only visible change is the issuer of the session tokens.

  • Schedule the cutover during a low-traffic window and notify users only if password resets are required.
  • Run the final export as close to cutover as possible to minimize delta records.
  • Keep the old provider running in read-only mode for a defined overlap period so you can redirect traffic back if something fails.
  • Update DNS, application configuration, and SDK endpoints to point at Bastionary.
  • Monitor authentication success rates, error logs, and support tickets for at least 48 hours after cutover.

If you cannot run both systems in parallel, take a full database snapshot before cutover and keep the old export file encrypted and available for rollback.

Stay portable after migration

Lock-in is a habit, not a one-time event. After you migrate, keep your data portable so the next move is easier.

  • Run a full user export from Bastionary monthly and store it in a separate location.
  • Document the schema, hash formats, and claim mappings for your team.
  • Avoid embedding provider-specific logic in application code. Treat identity objects as first-class data with well-defined ownership.
  • Periodically review admin workflows and support tools to ensure they produce clear audit evidence.

Next steps

  • Run the inventory checklist against your current provider.
  • Build the normalization script for your specific export format.
  • Deploy a staging Bastionary instance and import a sample of real users.
  • Document the cutover runbook and rollback procedure before going live.

Run it yourself

Bastionary is free, open-source software. Follow the quick start to have it running on your own server, or browse the releases on Git.

Get started