# How Clokeep works

> What connects to what, where your backups travel and what Clokeep keeps about them.

Clokeep has two parts: the panel you sign in to, and an agent on each server you back up.

## The panel and the agent

The panel at [app.clokeep.com](https://app.clokeep.com) holds your settings: servers, storages, plans and schedules. It decides when a backup is due and records every run.

The agent is a small program on your server. It reads your files or databases, packs them into an archive and uploads the archive to your storage.

## Who connects to whom

The agent opens every connection between your server and Clokeep. It connects out to the panel over HTTPS to check in, pick up runs and report on them. By default it checks in, and asks for new work, every 15 seconds.

The panel never connects to your server. You open no inbound ports for Clokeep.

The agent also connects straight to your storage.

The panel connects to your storage too. It does so to:

- test the connection, and test it again every hour
- check every hour that each backup is still on the storage
- delete backups that [retention](/docs/backups/schedules-retention#retention) no longer keeps, or that you delete
- read a backup's file list when you [browse it](/docs/restores/browse)
- send you a backup when you [download it](/docs/restores/download-share), except a whole unencrypted backup on S3, which your browser fetches from the bucket
- fetch and pin an [SFTP storage's host key](/docs/storage/sftp#the-host-key) when you save the storage

Like the agent, the panel checks an SFTP storage's pinned host key and an FTPS server's certificate before it signs in.

Your storage must accept connections from the panel as well as from your servers.

### The panel's addresses

If your storage accepts connections only from known addresses, allow the addresses the panel connects from. When Clokeep publishes them, the storage form shows them at the top, for example "If your storage only accepts connections from known addresses, allow: 203.0.113.10, 2001:db8::10. The panel uses these for Test connection, browsing, downloads, retention deletes and hourly checks. Your servers' agents connect from the servers themselves."

The addresses in this example are placeholders. Use the ones your storage form shows. The API returns the same list as `panel_egress_ips` from `GET /platform`. When Clokeep has not published them, the form shows no notice and the list is empty.

Allow your servers' own addresses too, for the agent's uploads and restores.

## Where your data goes

During a backup, the agent copies the data into its work folder on your server, builds the archive there and uploads it straight to your storage. It deletes that run's files when the run ends. The work folder keeps copies of recent indexes, so the next incremental backup does not download them again. The backup's contents do not pass through the panel on the way to your storage.

With more than one storage, the agent uploads to the first in priority order and tries the next if that upload fails.

Next to each archive, the agent uploads an index, the backup's file list. The index lists every file in the backup with its path, size, modified time, permissions and owner. For incremental plans that keep deduplication on, it also holds a checksum of each file's contents.

When your backups are [encrypted](/docs/backups/encryption), the agent encrypts each archive on your server before it uploads it. From agent 3.3.0, it encrypts the index of an encrypted backup too. Otherwise the index is plain: anyone who can read your storage can read it.

### What the panel keeps

- Your settings. Storage credentials and database passwords are stored encrypted.
- What the agent reports about each server: its host name, operating system, IP address, control panel and agent version.
- On Plesk and cPanel servers only, each hosting account: its domain, system user, folders, mailboxes and database names.
- Each run: its status, its times, its progress and its log lines.
- Each backup: where it sits on your storage, its size, a SHA-256 checksum of the archive, how many files it holds, their total size and the names of its top-level folders.
- Where each backup's index sits on your storage, with the index's checksum.

The list of files itself stays on your storage, in the index. Some older backups are the exception: the panel keeps their file lists in its own database.

When the agent picks up a run, the panel sends it what the run needs, including the storage credentials.

### When your data passes through the panel

Some actions read your backups through the panel:

- When you browse a backup's files, the panel downloads its index from your storage. It checks the index against its checksum and keeps a copy in a cache. An encrypted index is decrypted in the panel to show it.
- When you download a file or a folder, the panel reads it from your storage and streams it to your browser. A [share link](/docs/restores/download-share#share-a-link) works the same way.
- When you download a whole backup, or open a share link of one, the panel streams it in the same way, with one exception. A backup that is not encrypted, on an S3 storage, comes straight from your bucket: after its checks, the panel sends the browser to a link on the storage that works for 5 minutes by default. See [Where a download comes from](/docs/restores/download-share#where-a-download-comes-from).
- To take one file or folder out of some archives, the panel first copies the archive to a temporary file. It deletes that file when it is done.

A backup does not go through the panel either: the agent uploads it straight to your storage. A restore does not go through the panel. The agent downloads the backup from your storage to your server and restores it there. If the server a backup came from is lost, see [Restore to a new server](/docs/restores/new-server).

## What a run is

A run is one backup or one restore. A plan runs one backup at a time: while a backup is **Queued** or **Running**, the plan starts no other. A server runs one restore at a time.

When a plan's schedule is due, or you click **Run now**, the panel creates a run with the status **Queued**. The agent picks it up on its next check-in, and the run turns **Running**. The run page shows these steps for a backup: **Prepare**, **Dump**, **Archive**, **Compress**, **Upload** and **Index**. **Dump** copies the files or dumps the database. **Index** uploads the index next to the archive.

A restore run shows its own steps: **Download**, **Extract**, **Restore** and **Verify**.

A run ends as **Completed**, **Partially completed**, **Failed** or **Cancelled**. A partially completed run failed for some items, but the backups it stored are kept and can be restored.

## When a server is offline

A server shows **Offline** when its agent has not checked in for a few minutes.

If a backup is due while the server is offline, the panel still creates the run. The run waits as **Queued** and does not time out. When the agent checks in again, it picks the run up and the backup runs then. While that run waits, later scheduled times of the same plan start no new run.

If the agent stops in the middle of a run, for example after a restart, it no longer holds the run. When it checks in again, the panel marks the run **Failed** and raises a **Backup run failed** alert, or **Restore failed** for a restore. Run it again.

If the agent reports nothing on a **Running** run for 12 hours, for example because the server is switched off or the agent hangs, the panel marks the run **Failed** with the error "The agent reported nothing on this run for 12 hours". It raises the same alert, and the plan can run again. A run whose stop you requested is marked **Cancelled** instead.

Every hour, Clokeep looks for agents that stopped checking in and raises an **Agent offline** alert for each one. It also raises a **Backup overdue** alert for a plan with no successful backup in time for its schedule. An Admin chooses where alerts go on the **Alerts** page, under **Settings**. See [Alerts](/docs/backups/alerts).

## Next steps

<CardGroup cols="2">
<Card title="Quickstart" href="/docs/quickstart" icon="play">
Add a storage and a plan, then run your first backup.
</Card>
<Card title="Install the agent" href="/docs/servers/install-agent" icon="term">
Put the agent on a server and see it come online.
</Card>
</CardGroup>
