> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lekalao.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Upgrades and backups

> Move to a new version without losing anything, and know how to restore it all.

## Upgrade

```bash theme={null}
cd /var/www/lekalao
php artisan down --render="errors::503"

git pull
composer install --no-dev --optimize-autoloader
npm ci
npm run build
php artisan migrate --force

php artisan config:cache
php artisan route:cache
php artisan view:cache

php artisan horizon:terminate
sudo systemctl restart lekalao-smtp   # when the relay runs

php artisan up
```

<Tip>
  While the site is `down`, tracked links and open pixels answer 503: those
  clicks are lost. Pick a moment with no campaign going out, and keep the
  window short.
</Tip>

Before a major upgrade, read the release notes and take a backup.

### What the migrations do on their own

Some versions repair existing data. For example, an installation with no platform administrator is given one, its oldest account, so that Horizon stays reachable.

## Back up

| What                        | Why                                                            |
| --------------------------- | -------------------------------------------------------------- |
| **The PostgreSQL database** | Everything: lists, subscribers, content, statistics, settings. |
| **`storage/app`**           | Media, imports in progress, exports.                           |
| **`.env`**                  | `APP_KEY` above all.                                           |

```bash theme={null}
# Every night
pg_dump --format=custom --file=/backups/lekalao-$(date +%F).dump lekalao
tar czf /backups/lekalao-storage-$(date +%F).tar.gz -C /var/www/lekalao storage/app
```

Redis needs no backup: it only holds queues and cache. A lost job is picked up again: sends that got stuck are queued again every ten minutes.

<Warning>
  Without `APP_KEY`, a restored database still works, but the providers'
  credentials, the webhook secrets and the accounts' two-factor secrets are
  unreadable. Keep the key apart from the backups, in a vault.
</Warning>

## Restore

```bash theme={null}
php artisan down
sudo -u postgres dropdb lekalao && sudo -u postgres createdb --owner=lekalao lekalao
pg_restore --dbname=lekalao /backups/lekalao-2026-09-17.dump
tar xzf /backups/lekalao-storage-2026-09-17.tar.gz -C /var/www/lekalao
php artisan migrate --force
php artisan horizon:terminate
php artisan up
```

Then check with `php artisan lekalao:diagnose`.

## Move to another server

1. Install Lekalao on the new server, **with the same `APP_KEY`**.
2. Restore the database and the files.
3. Point the DNS at it.
4. The providers' feedback addresses and the links already sent keep working, as long as the public address does not change.
