pulumi stack export --file stack.json writes the full deployment checkpoint, and pulumi stack import --file stack.json writes it into the currently selected stack. This pair is the supported way to migrate between backends, for example from the local file backend to Pulumi Cloud, without destroying and recreating infrastructure.
The procedure is to export from the source, log in to the target backend, create the stack there, and import. Resource URNs and provider IDs are preserved, so the next pulumi up reports no changes. Confirm that before doing anything else; a plan proposing to create everything means the import did not land.
Secrets are the complication. The exported checkpoint contains ciphertext tied to the source stack's secrets provider, so importing into a stack with a different provider yields undecryptable values. Either create the target stack with the same provider, or run pulumi stack change-secrets-provider after the import while the old key is still available. The export format is versioned and an export from a much newer CLI may not import into an older one.