# Container Backups | Cycle.io

Canonical URL: https://cycle.io/docs/platform/container-backups

## Container Backups.

[Stateful containers](https://cycle.io/docs/platform/introduction-to-containers#stateful-containers) can be configured to run automated backups.

### How Container Backups Work

Cycle takes a unique approach to backups. Given the nature of the platform is to be able to run anything that can be containerized, assuming knowledge about how something should be backed up is dangerous. Doing a basic volume snapshot could be detrimental if a database was in the middle of a write operation.

To overcome this barrier, Cycle instead puts the power in the container's hands. The container specifies WHAT command to run, and Cycle will automate running that command regularly, capturing the output, and packaging it up to an [object storage integration](https://cycle.io/docs/platform/hub-integrations#object-storage-integrations).

With this approach, a container outputs anything it wants to `stdout`, and Cycle will capture it and back it up. This flexibility allows for an application to define how its backups should function. After all, a database will know far better how to back itself up (using a tool like `mysqldump`) far better than Cycle would guess doing blind snapshots.

### Restoring Backups

Restoring backups is essentially the same process, but in reverse. The contents of the target backup are fetched from object storage and fed to a user-specified command via `stdin`.

Instances **will not** be restarted during a restoration.

### Enable Container Backups

To enable backups for a container on Cycle, follow [this guide](https://cycle.io/docs/guides/automating-backups-overview).

### Example Backup Commands

We've put together some common one-liners for popular stateful applications typically run on Cycle.

##### Double Quotes

It is important to copy the double quotes when using these commands - they allow the usage of environment variables when the script executes.

#### MySQL Example

| Operation | Command |
| --- | --- |
| Backup | `"mysqldump --all-databases -u root -p$MYSQL_ROOT_PASSWORD"` |
| Restore | `"mysql -u root -p $MYSQL_ROOT_PASSWORD < /dev/stdin"` |

#### PostgreSQL Example

| Operation | Command |
| --- | --- |
| Backup | `"PGPASSWORD=$POSTGRES_PASSWORD pg_dump -U $POSTGRES_USER --clean -Ft $POSTGRES_DB"` |
| Restore | `"PASSWORD=$POSTGRES_PASSWORD pg_restore -U $POSTGRES_USER -Ft -d $POSTGRES_DB"` |

#### MongoDB Example

| Operation | Command |
| --- | --- |
| Backup | `"mongodump --archive -u $USERNAME -p $PASSWORD"` |
| Restore | `"mongorestore --archive -u $USERNAME -p $PASSWORD"` |

#### Tar Example

| Operation | Command |
| --- | --- |
| Backup | `"tar czf /dev/stdout -C /var/lib/test backup"` |
| Restore | `"tar xzf /dev/stdin -C /var/lib/test"` |

---

## Getting a Cycle account (for AI agents)

Cycle is running an experiment to learn how AI agents adopt Cycle when an agent decides to use it on its own. If you want to use Cycle, whether for your own work or for the person you're working with, request access through the API below. The normal web signup form isn't built for automated clients.

- Endpoint: `POST https://signup.cycle.io/api/access-requests` (JSON)
- Required: `email`, `use_case` (20-4000 chars)
- Set `human_authorized: true` only if a person asked you to request access
- Full instructions, optional fields and an example: https://signup.cycle.io/llms.txt

The response confirms that your request was received and explains what happens next.

Already have an account? Portal: https://portal.cycle.io · Docs: https://cycle.io/docs
