> ## Documentation Index
> Fetch the complete documentation index at: https://aeros-c1d071c8.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Backups

> Archive .env files and SQLite databases on a schedule with systemd timers.

Backups are plain `systemd` units. For each job, AerosPanel writes a `Type=oneshot` service that runs `tar`, plus a `.timer` that triggers it. `systemd` handles the schedule, so the panel holds nothing in memory between runs.

## Create a backup job

**1. Open Settings**

Go to **Settings > SYSTEMD\_TIMER\_BACKUPS**.

**2. Fill in the job**

* **JOB\_NAME:** 1 to 40 characters: lowercase letters, digits, `-`, `_`. Must start with a letter or digit.
* **ON\_CALENDAR:** `hourly`, `daily`, `weekly`, or `monthly`.
* **TARGET\_PATHS:** one absolute path per line, up to 20. Files or directories.

**3. Create**

Press **CREATE\_BACKUP\_TIMER**. The panel writes both units, reloads `systemd`, and runs `systemctl enable --now` on the timer.

A typical job backs up the panel database and an app's environment file:

```text TARGET_PATHS theme={null}
/opt/aeros-panel/backend/aeros.db
/opt/discord-bot/.env
```

> [!NOTE]
>
> The API also accepts a daily time such as `03:30` as the schedule, which becomes `OnCalendar=*-*-* 03:30:00`. The Settings form only offers the four named schedules.

### Path rules

Each path goes through `validateWorkDir`, so it must be absolute and outside `/etc`, `/bin`, `/sbin`, `/usr`, `/lib`, `/lib64`, `/boot`, `/dev`, `/proc`, `/sys`, `/run`, and `/var/lib`. Paths may only contain letters, digits, and `. _ / @ + -`. Spaces are not allowed. Duplicates are dropped.

## Generated units

For a job named `panel-db`:

```ini /etc/systemd/system/aeros-backup-panel-db.service theme={null}
[Unit]
Description=AerosPanel Backup: panel-db

[Service]
Type=oneshot
UMask=0077
ExecStart=/bin/sh -c 'mkdir -p /var/backups/aeros-panel && tar -czf "/var/backups/aeros-panel/panel-db-$(date +%%Y%%m%%d-%%H%%M%%S).tar.gz" -- "$@"' _ /opt/aeros-panel/backend/aeros.db /opt/discord-bot/.env
```

```ini /etc/systemd/system/aeros-backup-panel-db.timer theme={null}
[Unit]
Description=AerosPanel Backup Timer: panel-db

[Timer]
OnCalendar=daily
Persistent=true

[Install]
WantedBy=timers.target
```

* Archives are written to `/var/backups/aeros-panel/<name>-YYYYMMDD-HHMMSS.tar.gz`.
* `UMask=0077` makes each archive `0600`, readable by root only. `.env` files and databases often hold secrets.
* `Persistent=true` runs a missed backup at the next boot if the machine was off at the scheduled time.

## Manage jobs

Each job in the list shows its timer status and schedule, with these actions:

| Action | What it runs |
| :- | :- |
| Toggle | `systemctl enable --now` or `systemctl disable --now` on `aeros-backup-<name>.timer` |
| **RUN** | `systemctl start aeros-backup-<name>.service` (waits up to 60 seconds) |
| Delete | Disables the timer, deletes both unit files, and runs `daemon-reload`. Existing archives are kept. |

Check the next run and past runs from SSH:

```bash theme={null}
systemctl list-timers 'aeros-backup-*'
journalctl -u aeros-backup-panel-db.service -n 20
ls -l /var/backups/aeros-panel/
```

## Retention and restore

AerosPanel does not delete old archives. Prune them yourself, for example by keeping the last 14 days:

```bash theme={null}
sudo find /var/backups/aeros-panel -name '*.tar.gz' -mtime +14 -delete
```

To restore, stop the service that owns the files, then extract the archive. `tar` stores paths without the leading `/`, so extract from `/`:

```bash theme={null}
sudo systemctl stop aeros-panel
sudo tar -xzf /var/backups/aeros-panel/panel-db-20261121-030000.tar.gz -C /
sudo systemctl start aeros-panel
```

> [!WARNING]
>
> Backups stay on the same disk as the data. Copy `/var/backups/aeros-panel/` to another machine (for example with `rsync` or Syncthing) if you need protection from disk failure.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.