# Operations

Day-to-day management of your containers: updates, backups, and maintenance.

## Updating Containers

The default `ghcr.io` registry images are versioned using tags.

- `:latest` - Builds daily from the upstream project's latest stable release.
- `:pkg` - Builds from FreeBSD quarterly packages.
- `:pkg-latest` - Builds from FreeBSD latest packages.

### Podman CLI

1. **Pull new image**:

   ```
   podman pull ghcr.io/daemonless/radarr:latest
   ```
2. **Stop and remove old container**:

   ```
   podman stop radarr
   podman rm radarr
   ```
3. **Start new container**: Run your original `podman run` command again. Since `/config` is a volume, your data persists.

### Podman Compose

1. **Pull new images**:

   ```
   podman-compose pull
   ```
2. **Recreate containers**:

   ```
   podman-compose up -d
   ```

   This automatically stops the old container and creates a new one *only* if the image has changed.

> [!WARNING]
>
> **Check that it really restarted**
>
> `podman-compose up -d` can exit 0 after failing to recreate a container. Check `podman ps`: the container's CREATED time should be just now.

### Automated Updates

`podman auto-update` drives systemd units, which FreeBSD does not have. Schedule the pull and recreate instead, for example from `/etc/crontab`:

```
# m  h  dom mon dow who   command
30   4  *   *   *   root  cd /containers/radarr && /usr/local/bin/podman-compose pull && /usr/local/bin/podman-compose up -d
```

[fjord](<https://fjord.daemonless.io>) updates a stack in one click and can roll the update back.

### AppJail Director

`appjail-director up` leaves a running jail alone unless its spec changed. To move a service to a newer image, destroy its jail and bring the project up again; `container: args:--pull` in the service's options pulls the image as it rebuilds:

```
appjail stop radarr
appjail jail destroy -f radarr
appjail-director up
```

A sidecar in a bundle (a database, Redis) has no `--pull`: pull its image first with `buildah pull --policy always <image>`.

## Backups

Backing up your data is critical. All daemonless containers store persistent data in the volume mounted to `/config`.

### Backup Strategy

1. **Stop the container**: Ensure database integrity (Radarr, Sonarr, etc. use SQLite).

   ```
   podman stop radarr
   ```
2. **Archive the config directory**:

   ```
   tar -czvf radarr-backup-$(date +%F).tar.gz /path/to/config/radarr
   ```
3. **Restart the container**:

   ```
   podman start radarr
   ```

### ZFS Snapshots

If your data is on ZFS, you can use snapshots for instant backups without long downtime.

```
# Snapshot
zfs snapshot zroot/data/config@backup-$(date +%F)

# Rollback (if needed)
# 1. Stop container
# 2. Rollback
zfs rollback zroot/data/config@backup-2024-01-01
# 3. Start container
```

## Maintenance

### Pruning Images

Over time, old image layers can accumulate.

```
# Remove unused images
podman image prune

# Remove all unused images (including untagged)
podman image prune -a
```

### Checking Logs

If a container fails to start:

```
podman logs radarr
```

Everything the container prints, setup and app alike, is in `podman logs`. On most images the app is the container's process: when it crashes, the container exits and the restart policy brings it back. Multi-service appliances restart the crashed service inside the running container instead. Either way the crash is in the log:

```
podman logs --tail 100 radarr
```

Apps that write their own log files keep them under `/config` (for example `/path/to/config/radarr/logs/`).
