Moving emails and user data (calendar etc) to new server

Your question

Since the v0.16 upgrade failed for me, I didn’t have time to re-do the migration. I was thinking that I could create a new server with better configuration (now that I’m more familiar with stalwart), and some other things… In general, I was thinking of creating a new server, migrating some data (like emails, calendar, contacts etc), and changing the IP of the A Record in my dns settings.

Is there a way (or if you find it advisable/possible at all), to move data from a stalwart server to another?

For the emails, I could probably use imapsync, but what about the rest of the user data?

Thanks in advance

The built-in export/import tool is exactly what you need for a full server-to-server migration, and it covers everything – emails, calendars, contacts, and all other stored data.

The recommended approach: use Stalwart’s built-in --export / --import utility. It creates a complete binary dump of the entire internal database (all subspaces: data, registry, blob, changelog, queue, report, telemetry, tasks), which can then be imported into a fresh Stalwart instance – even one configured with a different storage backend.

Here is the workflow:

  1. Stop the old server (required – running the export on a live server risks data inconsistency).
  2. Export the full database from the old server:
    /opt/stalwart/bin/stalwart --config /opt/stalwart/etc/config.json --export ~/stalwart-export
    
  3. Set up your new server, configure it as desired, but keep it stopped.
  4. Import the dump into the new server:
    /opt/stalwart/bin/stalwart --config /opt/stalwart/etc/config.json --import ~/stalwart-export
    
  5. Start the new server, then switch your DNS A record.

A few notes:

  • The export supports selective subspace export via the EXPORT_TYPES environment variable (e.g. EXPORT_TYPES="blob,data") if you only want to move certain data types. Leaving it unset exports everything.
  • The import always imports all subspaces present in the dump – you can’t filter at import time.
  • This tool is described as a migration aid, not a substitute for routine backups, so keep your existing backup strategy in place.

Your imapsync idea would also work for emails specifically, but the export/import route handles calendars, contacts, and all other data in one shot.

Reference: Database Migration docs

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

What if the old server is in v0.15 (like in my case). Does the export tool exist in that version?

Edit: Just saw you can download it separately. I will give it a shot.

The tool for this is Vandelay: you run vandelay import against the old server’s JMAP API into a per-account archive, then vandelay export onto the new server. It carries the full per-account data set: mail, mailboxes, sieve, contacts, calendars and files. It’s documented under
stalw.art/docs/migration.

You don’t need anything special installed on the 0.15 side; Vandelay is a separate tool you run against the existing server’s API (use the “Older Stalwart” path for a 0.15 source, where files are read over WebDAV rather than JMAP). If you’re not after zero-downtime, you can just run it per account and then switch DNS over.

Perfect! Yeah, zero downtime is not needed here. I will try it at first chance and report back for the record.