# Running a site

URL: https://rustpress.witsberry.com/running-a-site/

> Day-to-day RustPress: email setup, backups and restoring, logs, automatic cleanup, a security checklist and fixes for common problems.

This page covers what you do once a site is online: email, the site address, logs, backups, cleanup, security and fixing common problems. To put a site online first, see [Hosting](/hosting/).

## Email

Password resets, comment notices and plugin mail go out in the background. Set up sending under **Settings › Email**: SMTP (your email provider, or a service such as Postmark, Mailgun, Amazon SES or Resend) or the server’s `sendmail`. *Send test email* checks it and shows any error. Failed mail is retried for a few hours.

## Site address

The address saved at setup is used for every link. To move to a new domain, or from `http://` to `https://`, change *Software Address* and *Site Address* under **Settings › General**, or from the shell:

```
rp option set siteurl https://example.com --root /srv/mysite
rp option set home https://example.com --root /srv/mysite
```

## AI agents

Open **AI › Agents**, pick a provider, paste an API key and choose a model. Keys are stored encrypted with the site’s `secret_key` and never shown again. Set a daily token limit there to cap costs. What you type, and the site content an agent reads, is sent to the provider you chose; use a local model (Ollama, LM Studio) if nothing may leave the server. More in [AI agents](/ai-agents/).

## Logs

**Tools › Logs** shows what went wrong, day by day: plugin failures and PHP errors, theme and template errors, database errors, crashes, failed emails and scheduled events, update problems, and JavaScript errors from visitors’ and admins’ browsers (only from the site’s own pages, rate-limited). Filter by level, source and text, download a day, or press *Ask an agent* to hand an error to an AI agent.

The files are in `rp-content/logs/`, one per day, split into parts of `log_max_lines` lines, never served on the web, with passwords, tokens and keys masked. Logs older than 30 days are removed by the daily cleanup. The same lines go to standard error: `journalctl -u rustpress` under systemd, `docker logs mysite` in Docker.

## Backups

**Back up the whole site folder**: `rp-config.toml` and `rp-content/`. The config holds the secret key that encrypts stored AI keys and signs logins, so keep it with the backup.

*   **SQLite:** copy the folder while the server is stopped, or take a live copy with `sqlite3 rp-content/database.sqlite ".backup backup.sqlite"`.
*   **MySQL or MariaDB:** `mysqldump rustpress > rustpress.sql`, plus the site folder for uploads, themes and plugins.
*   **PostgreSQL:** `pg_dump rustpress > rustpress.sql`, plus the site folder.
*   `rp backup` zips every theme and plugin. `rp export-content site.xml` writes a WordPress export file that RustPress or WordPress can import.

A simple nightly backup with SQLite, in the `rustpress` user’s crontab, keeping one copy per weekday:

```
0 3 * * * sqlite3 /srv/mysite/rp-content/database.sqlite ".backup /srv/backups/db-$(date +\%a).sqlite" && tar czf /srv/backups/files-$(date +\%a).tar.gz -C /srv/mysite rp-config.toml rp-content/uploads rp-content/themes rp-content/plugins
```

Copy `/srv/backups` off the server too. **Restoring:** stop the server, put the site folder back (and load the SQL dump for MySQL or PostgreSQL), and start the server.

## Automatic cleanup

Once a day RustPress clears what it no longer needs: AI temporary and build files, uploaded zips after 30 days, AI workspace projects untouched for 30 days once installed (90 days if never installed, and never while a change waits for approval), rollback copies after 90 days (the newest change of each project always keeps its copy), file-editor backups after 90 days, trash and spam after 30 days, auto-drafts after 7 days, and logs over 5 MB are rotated.

The database tidies itself too: data nothing points to any more (metadata of deleted posts, comments, terms and users, expired transients) is cleared daily, and tables are compacted weekly. **Tools › Database** shows every table with its owner and row count, optimizes on demand and lists data left by removed plugins. **Tools › Site Health** shows what uses space and has *Clean up now*.

```
rp cleanup --dry-run           # what would go
rp cleanup                     # do it now
rp db optimize --revisions 5   # compact tables, keep 5 revisions per post
rp db leftovers                # data left by removed plugins
rp db plugin-data SLUG --remove
```

## Security checklist

*   Serve the site over HTTPS and keep RustPress on `127.0.0.1` behind the proxy.
*   Run it as its own user (`rustpress`), never as root.
*   Protect the config: `chmod 600 /srv/mysite/rp-config.toml`. It holds the secret key and the database password.
*   On production, consider `disallow_file_edit = true` (no code editing from the admin) and, once set up, `disallow_file_mods = true` (no installing plugins, themes or updates from the admin; `rp update` still works).
*   Install plugins only from sources you trust. PHP, Node and Python plugins run as programs with the `rustpress` user’s rights; JavaScript and WebAssembly plugins are sandboxed. The Plugins screen shows what each plugin may access and flags full access.
*   Keep RustPress updated and keep backups off the server.
*   Use strong administrator passwords. Only administrators can use AI agents.

Everything RustPress does to protect a site is in [Safety and limits](/safety-and-limits/).

## Troubleshooting

| Problem                                                      | Fix                                                                                                                                                                                           |
| ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *Address already in use*                                     | Another program uses the port. Without `--listen` RustPress moves to the next free port; with it, pick another port or stop the other program.                                                |
| *Error establishing a database connection*                   | Check user, password, host and that the database exists. Test with `mysql -h HOST -u USER -p DATABASE` or `psql`.                                                                             |
| The site broke after a plugin or theme change                | Open `/rp-admin/safe-mode?on=1` (plugins off and the default theme, for you only), or start with `rp serve --safe-mode`. Changes made by AI agents can be rolled back under **AI › Changes**. |
| Links point to the wrong address                             | Fix `siteurl` and `home` (see Site address above).                                                                                                                                            |
| Uploads fail behind nginx                                    | Raise `client_max_body_size`.                                                                                                                                                                 |
| Emails don’t arrive                                          | **Settings › Email › Send test email** shows the error.                                                                                                                                       |
| *No permission to replace …* when updating                   | The program file belongs to another user: run `sudo rp update`, or move the program into a folder the `rustpress` user owns.                                                                  |
| A plugin shows *Restarted N times for using too much memory* | It probably leaks memory. Ask the QA Tester agent to review it, or deactivate it.                                                                                                             |
| An update went wrong                                         | Put `rp.previous` back and reload (see [Install and update](/install-and-update/)).                                                                                                           |
| An AI chat says *Stopped: the server restarted*              | The server was stopped during a run. Send a message to continue.                                                                                                                              |
| Forgot the admin password                                    | `rp user create newadmin you@example.com 'new-password' administrator --root /srv/mysite`, log in, and reset the old account.                                                                 |

Start with **Tools › Logs**. Settings and environment variables are listed in [Configuration](/configuration/).
