---
title: Maintaining Shopware on Shopware PaaS | Shopware Community Hub
description: >-
  Learn how to effectively maintain Shopware on Shopware PaaS, including backup
  strategies, updates, and monitoring.
canonical_url: 'https://hub.shopware.com/learn/unit/paas-maintaining-shopware-paas'
---

# Maintaining Shopware on Shopware PaaS

<LearningObjectives>

- Implement comprehensive backup and recovery strategies.
- Manage Shopware updates and maintenance schedules.
- Configure monitoring and alerting systems.
- Establish proper maintenance workflows and procedures.

</LearningObjectives>

# Maintaining Shopware on Shopware PaaS: Keeping Your Shop Healthy

Maintenance is the secret to a stable, secure, and high-performing Shopware shop. On Shopware PaaS, you have powerful tools for backups, updates, and monitoring—but you need a plan to use them effectively.

In this learning unit, you'll learn how to maintain your Shopware application effectively, from automated backups to monitoring and alerting to ensure smooth operation and avoid costly downtimes.

<Callout title="Why Maintenance Matters" type="info">

Regular maintenance prevents downtime, data loss, and performance issues. A well-maintained shop is always ready for customers and new features.

</Callout>

## Regular Maintenance: What to Do and Why

**Scenario:**
You're running a busy Shopware shop. Automated scripts clear caches, rotate logs, and optimize the database every night—so you sleep better, and your shop runs faster.

<Callout title="What is Logrotate?" type="info">

Use tools like **logrotate** to automatically manage log files.
It compresses, rotates, and deletes old logs on a schedule, preventing your server from running out of disk space.

**Example:** Shopware's var/log can be rotated daily, keeping only the last 14 days of logs.

</Callout>

### Automating Maintenance Tasks

Use scripts and scheduled jobs to handle routine tasks:

```bash
#!/bin/bash
# maintenance.sh
shopware ssh -p PROJECT_ID -e master 'php bin/console cache:clear'
shopware ssh -p PROJECT_ID -e master 'php bin/console cache:warmup'
shopware ssh -p PROJECT_ID -e master 'find var/log -type f -name "*.log" -mtime +7 -delete'
shopware ssh -p PROJECT_ID -e master 'php bin/console database:optimize'
```

<Callout title="Difference between cache:clear and cache:warmup" type="info">

- The **cache:clear** deletes all cached data (Twig templates, config, routing, etc.). Use it to remove outdated or invalid cache.
- The **cache:warmup** pre-builds the cache again with the current configuration and templates. Use it to make sure your shop is fast right after clearing the cache.

Best practice: Run both together, first **cache:clear** then **cache:warmup**.

</Callout>

**Scheduling with cron:**

```yaml
# .platform.app.yaml
crons:
    cleanup:
        spec: '0 0 * * *'
        cmd: 'php bin/console messenger:consume async --time-limit=3600'
    sitemap:
        spec: '0 3 * * *'
        cmd: 'php bin/console sitemap:generate'
    index:
        spec: '0 4 * * *'
        cmd: 'php bin/console elasticsearch:index'
```

## Monitoring and Alerting: Stay Proactive

Don't wait for customers to report problems—set up health checks and alerts so you know about issues first.

**Example:**

```php
// src/Monitoring/SystemHealth.php
namespace App\Monitoring;
class SystemHealth {
    public function checkSystemStatus(): array {
        return [
            'database' => $this->checkDatabase(),
            'cache' => $this->checkRedis(),
            'search' => $this->checkElasticsearch(),
            'queue' => $this->checkMessageQueue(),
        ];
    }
    private function checkDatabase(): bool {
        try {
            $this->connection->executeQuery('SELECT 1');
            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
}
```

**Log management:**

```yaml
# config/packages/monolog.yaml
monolog:
    handlers:
        main:
            type: fingers_crossed
            action_level: error
            handler: nested
            excluded_http_codes: [404, 405]
        nested:
            type: stream
            path: "php://stderr"
            level: debug
```

<Callout title="Tip" type="info">

Set up alerts for errors, disk space, and slow queries. Use Platform.sh integrations or external tools for notifications.

</Callout>

## Backup and Recovery: Be Ready for Anything

Backups are your safety net. Automate them, test them, and know how to restore them quickly.

**Example backup script:**

```bash
#!/bin/bash
# backup.sh
BACKUP_ID=$(shopware backup:create --yes --project PROJECT_ID --environment master)
shopware backup:wait "$BACKUP_ID"
shopware backup:download "$BACKUP_ID" --target ./backups/
find ./backups/ -type f -mtime +7 -delete
```

**Restoring from backup:**

```bash
shopware backup:restore $BACKUP_ID
shopware ssh 'php bin/console system:validate'
```

## Troubleshooting: Stay Ahead of Issues

- **Performance**: Use `shopware metrics` and SQL queries to spot slowdowns.
- **Cache**: Clear caches and check Redis status if you see odd behavior.
- **Logs**: Always check logs after updates or incidents.

## Hands-on Exercise: Practice Maintenance

1. Set up and schedule a maintenance script.
2. Configure monitoring and alerts.
3. Test your backup and recovery process.

## Common Pitfalls and How to Avoid Them

- **Forgetting to automate**: Manual maintenance is error-prone—use scripts and cron jobs.
- **Not testing backups**: Always test restores before you need them.
- **Ignoring alerts**: Set up notifications and act on them quickly.

## Additional Resources

- [Platform.sh Maintenance Guide](https://fixed.docs.upsun.com/environments/backup.html)
- [Shopware System Requirements](https://docs.shopware.com/en/shopware-6-en/first-steps/system-requirements?category=shopware-6-en/getting-started)
- [Platform.sh Monitoring Tools](https://fixed.docs.upsun.com/integrations/notifications.html)

## Key Takeaways

- **Automated Maintenance**: Implement automated scripts and scheduled jobs for routine maintenance tasks.
- **Backup and Recovery**: Establish comprehensive backup strategies and test recovery procedures.
- **Monitoring and Alerting**: Set up proactive monitoring to catch issues before they affect customers.
- **Troubleshooting**: Develop systematic approaches to diagnose and resolve common issues.

## Final Thoughts

Congratulations! You've now completed the entire Shopware PaaS Essentials learning path from planning and configuration to deployment, scaling, and long-term operation. You now have the skills and tools to build, migrate, and maintain reliable Shopware applications on PaaS.

Remember: PaaS evolves constantly, so stay connected with the Shopware community and follow best practices to keep your knowledge up to date.
