# Operations

Day-to-day tasks for a CrushMFT 27 container. The commands use Docker and a container named `crushmft27` with the volume `crushmft27`; for Compose use `docker compose ...`, for Kubernetes see [Kubernetes and Helm](Kubernetes.md#day-to-day).

## Start, stop, restart

| | |
|---|---|
| Stop | `docker stop -t 120 crushmft27`. CrushMFT gets the stop signal, lets running jobs and transfers finish, and ends. Without `-t`, Docker gives it only 10 seconds before it kills it. |
| Start | `docker start crushmft27`. A few seconds after the first start. |
| Restart | `docker restart -t 120 crushmft27` |
| Restart from the admin pages | CrushMFT ends with exit code **64** and the container stops. Docker starts it again only with a restart policy: run the container with `--restart unless-stopped` (or `always`, or `on-failure`). Kubernetes always starts it again. |
| After a reboot of the host | with `--restart unless-stopped` or `always`, Docker starts it |

To change the restart policy of an existing container: `docker update --restart unless-stopped crushmft27`.

## Reset the admin password

The password variables are only read when the admin user is first created. To set a new password for an existing admin:

```
docker stop crushmft27
docker run --rm -v crushmft27:/app/CrushMFT27 crushftp/crushmft27:latest -A crushadmin 'NewPassword-123'
docker start crushmft27
```

The middle command writes the user `crushadmin` with that password (`Admin user written to:./users/MainUsers/`) and ends. Use the same image tag as your container, and the same volume. Sign in and change the password again in the admin pages, since the one above is in your shell history.

In Kubernetes, stop the server, run the same once against its volume, start it again:

```
kubectl -n crushftp scale statefulset crushmft27 --replicas=0
kubectl -n crushftp run reset-admin --restart=Never --image=crushftp/crushmft27:latest --overrides='
{"spec":{"securityContext":{"fsGroup":65532},
 "containers":[{"name":"reset-admin","image":"crushftp/crushmft27:latest","args":["-A","crushadmin","NewPassword-123"],
   "volumeMounts":[{"name":"data","mountPath":"/app/CrushMFT27"}]}],
 "volumes":[{"name":"data","persistentVolumeClaim":{"claimName":"app-volume-crushmft27-0"}}]}}'
kubectl -n crushftp logs -f reset-admin          # until "Admin user written to"
kubectl -n crushftp delete pod reset-admin
kubectl -n crushftp scale statefulset crushmft27 --replicas=1
```

## Change a setting from outside

Put a file in `split_prefs/` in the volume ([Configuration](Configuration.md#settings-as-files-split_prefs)) and restart. With the `-dev` image as a helper:

```
docker run --rm -v crushmft27:/app/CrushMFT27 --entrypoint sh crushftp/crushmft27:latest-dev \
  -c 'mkdir -p /app/CrushMFT27/split_prefs && echo 1 > /app/CrushMFT27/split_prefs/_log_debug_level.txt'
docker restart -t 120 crushmft27
```

## Copy files in and out

`docker cp` works with the plain image too (not into a container started with `--read-only`; use the `-dev` image as a helper then):

```
docker cp crushmft27:/app/CrushMFT27/prefs.XML ./prefs.XML
docker cp ./my-plugin-settings.XML crushmft27:/app/CrushMFT27/
```

Files copied in belong to root; if the server must change them, fix the owner with the `-dev` image (`docker run --rm -v crushmft27:/app/CrushMFT27 --user 0 --entrypoint chown crushftp/crushmft27:latest-dev -R 65532:0 /app/CrushMFT27`).

## Backup and restore

See [Data and volumes](Data-and-Volumes.md#backup-and-restore).

## Update

See [Updates and versions](Updates-and-Versions.md). In short: start a newer image on the same volume; or let CrushMFT's updater do it.

## Size the container

| | |
|---|---|
| Memory | 2 GB for most servers; 1 GB at least. The server's heap is half of the limit ([Configuration](Configuration.md#java-memory-and-options)). Watch `docker stats`; a container killed for memory shows `OOMKilled` in `docker inspect`. |
| CPU | no limit needed. Encryption (SFTP, HTTPS) and compression use CPU in proportion to traffic. |
| Disk (volume) | 5 GB is plenty for settings, users, logs and a few versions. Logs grow with traffic: set the log rotation in the preferences. Your users' files need their own space. |
| Open files | CrushMFT keeps a file and a socket per transfer. Docker's default limit (1,048,576) is enough; a host with a low limit needs `--ulimit nofile=65536:65536`. |

## Several servers

One container per volume. For several CrushMFT servers serving the same users and settings, use CrushMFT's cluster (Enterprise license); each server has its own container and volume.

## Support

When asking CrushMFT support about a container, send:

- the image tag (`docker inspect crushmft27 --format '{{.Config.Image}}'`),
- the start of the log (`docker logs crushmft27 2>&1 | head -100`) and the part around the problem,
- how you start it (your `docker run` line, Compose file or chart values, without passwords).
