# The migration assistant

The migration assistant moves a CrushFTP 8, 9, 10 or 11 server into a new CrushMFT 27 folder: users, settings, jobs, shares, keys, certificates and the rest. You choose the old folder, it reads it, copies it, lets you try the copy beside the running old server, and then switches with the old server stopped for as short a time as it can.

**It only copies.** Nothing in the folder you choose is changed, moved or deleted. Every run records the old folder before and after and says in its report that it was not changed (or lists what the running old server wrote itself). Your old server keeps running until you switch, and stays as it was: that is your way back.

It is the control panel's **Migrate** tab, and the same on the command line (`-migrate`), which is the way on Linux servers.

CrushFTP 8, 9 and 10 move exactly as 11 does. A server with a DMZ moves together with its DMZ machines: see "A DMZ".

## Before you start

| | |
|---|---|
| **A new CrushMFT 27 folder** | unpacked and not started, or started only once. A folder with users, jobs or shares of its own is not filled unless you agree: those are moved to `backup/before_migration_<time>/` first (`--move-aside`). |
| **A CrushMFT 27 license** | the switch waits until the copy has one; a server without a license serves no users. See [License](Admin-License.md). |
| **Java 21 at least, 25 recommended** | see [Requirements](Requirements.md) |
| **Read access to the old folder** | on Linux it is often root's: run the assistant as a user who can read it |

## In the control panel

![The Migrate tab: the old copy, the copy, the review, the rehearsal and the switch's checklist](Upgrade-Migration-Assistant/tab.png)

**The old copy.** The CrushFTP folders found beside this one and in the usual places, each with its version; or type the folder's path. **Read it** reads the old folder and copies nothing.

![The old copy: the copy-only promise, a CrushFTP 11 folder found beside this one, the path and Read it](Upgrade-Migration-Assistant/old-copy.png)

**Review.** What comes over, in groups: **Needs you** (a choice or an action), **Converted** (with what changes), **Ready** (copied as it is), **Certificates**, **Skipped** (and why) and **Not in this copy**. The newest report opens from the card's button.

![The review of a CrushFTP 11 copy: what needs you, what is converted, copied as it is, certificates, skipped, and not in this copy](Upgrade-Migration-Assistant/review.png)

**Copy.** Copies everything into this folder with every path rewritten to point here. Choose what happens to the old administrator switches (kept as legacy roles, or converted to roles for the accounts that lose nothing, or for all), whether the copied database drivers may load, and whether the old server is stopped (then its statistics database is copied too). Run it again at any time: it copies only what changed since (see "Running it again").

![The first copy: the start check passed, each step's files, what CrushMFT's first start changed, the admin accounts converted](Upgrade-Migration-Assistant/copy.png)

**Try it.** **Start the rehearsal** starts the copy as a server beside the old one, on this computer only, with every port moved to a free port from 40000 up. Sign in with an old account to try it. **Compare certificates** asks every TLS port of both servers the way a client does and compares what they serve. **Open its admin page** opens the copy's own admin pages.

![The rehearsal running: each old port and the port the copy uses instead; every TLS port serves the same certificate](Upgrade-Migration-Assistant/try-it.png)

**Switch.** **Check** shows the checklist and how long the server will be away. **Switch now** stops the old server and starts CrushMFT on its ports. Your system asks for an administrator once (macOS: the password; Windows: the approval). Once switched, **Go back to the old server** is here.

![The switch's checklist: here a copy without its CrushMFT license, and the Needs you list not yet read, stop the switch](Upgrade-Migration-Assistant/switch.png)

## On the command line

```
java -jar CrushMFT.jar -migrate <old folder> [what] [options]
```

Run it in the CrushMFT 27 folder. On Linux, `sh crushmft_init.sh migrate <old folder> [what] [options]` does the same from anywhere.

| What | Does |
|---|---|
| (nothing) or `--scan` | reads the old folder and prints the review; copies nothing |
| `--copy` | copies; run again, it copies what changed |
| `--check` | the start check alone: does any setting still point into the old folder |
| `--rehearse` | starts the copy beside the old server until Ctrl-C or `./crushftp_quit` |
| `--tls-proof` | while the rehearsal runs: compares what each TLS port serves on both servers |
| `--cutover` | the switch, as root or an administrator; asks first unless `--yes` |
| `--way-back` | stops CrushMFT and starts the old server again; asks first unless `--yes` |
| `--dmz-prepare` | on a DMZ machine, with the CrushFTP 11 DMZ's folder: CrushMFT's start settings for the same DMZ port; nothing is started |
| `--dmz-switch` | on a DMZ machine, as root or an administrator: the CrushFTP 11 DMZ stopped, CrushMFT's started; prints its pairing code |
| `--dmz-switch-back` | on a DMZ machine: CrushMFT's DMZ stopped, the CrushFTP 11 DMZ started again |

| Option | With | Does |
|---|---|---|
| `--convert-rbac=none`, `safe`, `all` | `--copy` | the old administrator switches: kept as legacy roles (none, the default), converted for the accounts that lose nothing (safe), or for every one (all). See [Roles from version 11](Security-Roles-from-11.md). |
| `--allow-unsigned-drivers` | `--copy` | lets the copied database drivers in `plugins/lib` load |
| `--copy-plugin=<name>` | `--copy` | copies a plugin of another maker |
| `--legacy-stopped` | `--copy` | the old server is stopped: its statistics database and AS2 spool are copied too |
| `--le-without-account` | `--copy` | moves the Let's Encrypt plugin's items although its authority cannot be reached; a new account is made at the next order |
| `--move-aside` | `--copy` | this folder's own users, jobs and settings go to `backup/before_migration_<time>/` first |
| `--keep-legacy-auto` | `--cutover`, `--dmz-switch` | leaves the old service starting at boot (by default it is set to start by hand) |
| `--dmz-code=<port name>=<code>` | `--cutover` | the pairing code a DMZ printed at `--dmz-switch`, for the DMZ port of that name; once per DMZ port |
| `--once` | `--copy` | does nothing when this folder holds a copy already (a container's start) |
| `--needs-ok` | `--copy` | ends with 0 when the copy finished with things that need you (a container's start) |
| `--yes` | `--cutover`, `--way-back` | does not ask |
| `--no-system` | any | leaves the system's own folders alone (`/Library`, `/etc`): for a container |

It ends with 0 (done), 1 (done, with things that need you), 2 (refused: a check failed, nothing changed) or 3 (failed).

## What comes over

| What | Then |
|---|---|
| **Users, groups, inheritance** | copied; their passwords work as before. Paths in a user that point into the old folder point into the new one; folders elsewhere (the files users see) are left where they are and used by both servers. Deleted users are copied too, so they can be restored. |
| **Settings** (`prefs.XML`, split settings) | copied with every path into the old folder rewritten. A setting still at the old default takes CrushMFT's new default; a security setting you chose yourself is kept, and the report lists it. |
| **Jobs** | copied. A job with several lines leaving one step is turned into a Branch; the original is kept beside it as `job.XML.v11`. |
| **Shares** (`TempAccounts`), **refresh tokens**, **certificate pins**, **forms**, **previews**, **S3 index** | copied |
| **SSH host keys** | copied, so SFTP clients see the same server; the report shows each key's fingerprint |
| **PGP keys** | copied with the key ring |
| **AS2** | copied; the spool only with the old server stopped (at the switch) |
| **Certificates** | each key store from inside the old folder becomes certificates kept by CrushMFT (one per distinct certificate), and each port serves the one the old server served, for every host name. The trust files for client certificates come along. A key store outside the old folder is listed where it is, not copied. See [TLS certificates](Prefs-Certificates.md). |
| **Let's Encrypt** | the LetsEncrypt plugin's certificates and account move into CrushMFT's own Let's Encrypt: [Let's Encrypt](ACME-Lets-Encrypt.md). Its authority is asked first; when it cannot be reached the step waits, and the next copy tries again. |
| **Statistics** | the old Derby database is copied at the switch (with the old server stopped) and imported in the background: [Importing from CrushFTP 11](Reports-Import-from-11.md). An external database is read where it is. |
| **Database drivers** in `plugins/lib` | copied; they load only when you allow it |
| **Plugins** | CrushMFT brings its own. A plugin that no longer exists is listed with what replaces it; another maker's is copied only when you name it. |
| **Logos and favicon** | copied and used. Own scripts and styles (`custom.js`, `custom.css`, changed login pages) are copied aside to `WebInterface/v11_custom/`, not used: the web interface is new. See [Changing how the WebInterface looks](Web-Customizing.md). |
| **The license** | not copied: CrushMFT 27 needs its own |
| **Logs**, **saved reports** | not copied; the report says where the logs are |

## Running it again

Copy as often as you like before the switch. Each run copies what changed in the old folder since the last one:

- changed in the old folder only: copied again;
- changed in this folder only (you fixed something while trying it): kept;
- changed in both: this folder's version is kept, and the old one is put in `migration/conflicts/<time>/`, listed in the report.

## The rehearsal

The copy runs as a real server, but holds back everything that would reach the old server's partners: ports move to 127.0.0.1 and free high ports (listed in `migration/rehearsal_ports.txt`); DMZ links, ServerBeat, replication and the cluster do not start; scheduled jobs, report schedules, alerts, mail, AS2 and certificate renewals are held. None of these holds is saved in the settings. Events still run when you try a login.

## The switch

The checklist first: a copy from this old folder, a license, no setting pointing back, the certificates compared, the review's Needs you read, the old server's service found, administrator rights. Then:

1. the rehearsal stops;
2. the old server is stopped through the system (the Windows service, the macOS daemon, the systemd unit or init script), never through a file in its folder, until its ports are free;
3. what changed since the copy is copied, with the statistics database and the AS2 spool;
4. CrushMFT's service is installed (or started, when it already is) with the old server's memory when that was more, and the old `-Dcrushftp.` Java switches as `-Dcrushmft.`;
5. as soon as it answers on all the old ports, the old service is set to start by hand, so a reboot does not bring it back.

Your users are without a server from step 2 to 5: in a test with a CrushFTP 11 init script on Linux, 10 seconds. The Switch card shows the estimate before and the real time after.

If anything fails between steps 2 and 5, the assistant stops CrushMFT, sets it to start by hand and starts the old server again at once.

## A DMZ

A CrushMFT 27 server and a CrushFTP 11 DMZ do not work together, so the DMZ machines switch at the same time as their server. In CrushMFT a DMZ is always paired with its server: the copied DMZ ports are paired at the switch with the code each CrushMFT DMZ prints.

1. **Before:** on each DMZ machine, unpack CrushMFT into a folder of its own and run there `java -jar CrushMFT.jar -migrate <the CrushFTP 11 DMZ's folder> --dmz-prepare`. It writes CrushMFT's start settings for the same port (`-dmz <port>`) and starts nothing. Copy and rehearse on the internal server as usual; the rehearsal does not link to any DMZ.
2. **At the switch,** on each DMZ machine, as root: `-migrate --dmz-switch`. The CrushFTP 11 DMZ stops, CrushMFT's DMZ starts (installed as its service), the old service is set to start by hand, and it prints a pairing code (also in `cluster/pairing_code.txt`, valid for an hour). From here the DMZ's users wait for the internal server.
3. **Then the internal server:** `--cutover --dmz-code=<the DMZ port's name>=<code>`, or the codes in the Switch card. Its checklist stops the switch while a DMZ still runs CrushFTP 11, does not answer, or has no code. After copying what changed, it pairs each DMZ port and starts CrushMFT; then it waits for the DMZ's own ports.

In a test with a CrushFTP 11 server and its DMZ on two Linux machines, the DMZ machine switched in 9 seconds and the internal server in 31, the DMZ's port answering through CrushMFT.

The way back: `--way-back` on the internal server, `--dmz-switch-back` on each DMZ machine. The assistant never connects to a CrushFTP 11 DMZ from its own machine, because such a DMZ takes the first address that connects as its server.

A DMZ on macOS is not switched by the assistant; on Windows its service starts with `-dmz <port>`.

## The way back

**Go back to the old server**, or `--way-back`: CrushMFT stops and is set to start by hand, the old service gets its start at boot back and starts. What CrushMFT alone recorded since the switch (new users, shares, job runs) stays in the CrushMFT folder; files your users uploaded are in the folders both servers use.

## The folder `migration`

| File | Holds |
|---|---|
| `report_<time>.html`, `copy_<time>.html` and `.json` | each run's report |
| `state.json`, `copied.tsv` | where the copy came from and what was copied, for the next run |
| `proof_<time>/` | the old folder recorded before and after the run |
| `conflicts/`, `removed/` | old versions of files changed on both sides, or gone from the old folder |
| `legacy_tls.json`, `certificates.json`, `tls_proof.json` | what the old server served, the certificates made from its key stores, the last comparison |
| `rehearsal_ports.txt`, `rehearsal_console.txt` | the rehearsal's ports and output |
| `cutover_result.json`, `cutover_console.txt` | how the last switch or way back ended |

## Containers and Kubernetes

Run the CrushMFT image once with the old folder mounted read-only at `/legacy` and the CrushMFT volume as usual: `-migrate /legacy --copy --no-system --once --needs-ok` as the image's arguments. The crushmft27 Helm chart does this for you before the first start when `migrateFrom.existingClaim` names the old server's volume claim (`subPath` when the folder is not at its top, `options` for more options of `-migrate`); remove it once the move is done. The switch in Kubernetes is scaling the old release to zero and starting the new one.

Doing it by hand, without the assistant, is described in [Upgrading from CrushFTP 11](Upgrade-from-11.md).

## Not tried for this page

The switch was run with CrushFTP 11 init scripts on Linux, a DMZ included; the Windows service, the macOS daemon and systemd were checked with a test, not with a real switch. The control panel's Switch button was not pressed on macOS or Windows. The Helm chart's `migrateFrom` was not installed on a cluster for this page; the container's `-migrate` was run.
