# Cleanup and uninstall

> Free disk by removing earlier data generations, replaced directories, old releases and recovery sets, and uninstall Corfedo.

Source: https://docs.corfedo.ai/operate/single-host/cleanup-and-uninstall/

Updates and restores keep what they replace, so you can go back. `cleanup` lists those items and removes the ones you choose. `uninstall` stops Corfedo and keeps its data until you delete it.

## Free disk

```sh
sh ~/corfedo/install.sh cleanup
```

It lists earlier data generations, replaced installation directories, inactive releases and recovery sets. Remove one item at a time, as listed:

```sh
sh ~/corfedo/install.sh cleanup --remove volume:corfedo-corfedo-postgres-1
```

The installer asks you to confirm in a terminal. Removal is permanent.

While an update is unfinished, its recovery set is not listed. The update continues from it and rolls back to it.

**Check:** `cleanup` no longer lists the item, and `status` still says `Ready.`

Keep at least the recovery set of the last update until you are sure you will not need to [restore](https://docs.corfedo.ai/operate/single-host/backup-and-recovery/) it.

## Uninstall

```sh
sh ~/corfedo/install.sh uninstall
```

After you confirm, it stops Corfedo and removes its containers and network. The data volumes, the installation directory and the recovery sets stay, and the command lists them.

> **Warning:** Deleting everything cannot be undone. Restore needs a recovery set, and step 2 removes them.

To delete everything:

1. Remove each listed volume with `docker volume rm NAME`.
2. Remove the installation directory, `~/corfedo` by default, with its `backups/`.
3. Remove the replaced directories next to it, `~/corfedo.previous-*` and `~/corfedo.restoring-*`. They hold keys and passwords too.
4. If you trusted the local certificate, remove it. On macOS, delete the **Caddy Local Authority** certificate from the System keychain. On Linux, delete `/usr/local/share/ca-certificates/corfedo-local.crt` and run `sudo update-ca-certificates`. Remove it from Firefox too.

To start Corfedo again on the kept data, apply the installed release again:

```sh
sh ~/corfedo/install.sh update --version "$(cat ~/corfedo/VERSION)"
```

## Related

- [Backup and recovery](https://docs.corfedo.ai/operate/single-host/backup-and-recovery/) explains what a recovery set holds.
