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

# Backups

> Back up your own data

<Warning>
  Lumi does not make automatic backups. Reinstalling the OS wipes the disk completely. Backups are your responsibility: keep them yourself and ahead of time, not once the data is already gone.
</Warning>

The idea is simple: you need to regularly pull a copy of important data **from the server to your own machine** (or to another server). Below are working approaches, from manual to fully automated. In every command, take `IP` and the `root` login from the server card in the bot.

<AccordionGroup>
  <Accordion title="1. Download files to your machine" icon="download">
    A one-off copy of a directory to your own computer. `scp` copies things "as is":

    ```bash theme={"system"}
    scp -r root@IP:/var/www ./backup
    ```

    `rsync` is handier for repeat copies — it transfers only what changed and runs faster:

    ```bash theme={"system"}
    rsync -avz root@IP:/var/www ./backup
    ```

    `-a` preserves permissions and structure, `-v` shows progress, `-z` compresses during transfer.
  </Accordion>

  <Accordion title="2. Database dump" icon="database">
    Copying database files directly is unreliable — you need a dump. Run the commands **on the server**, then pull the resulting file using the method from step 1.

    <Tabs>
      <Tab title="MySQL / MariaDB">
        ```bash theme={"system"}
        mysqldump -u root -p DB_NAME > db.sql
        ```

        All databases at once:

        ```bash theme={"system"}
        mysqldump -u root -p --all-databases > all.sql
        ```
      </Tab>

      <Tab title="PostgreSQL">
        ```bash theme={"system"}
        sudo -u postgres pg_dump DB_NAME > db.sql
        ```

        All databases at once:

        ```bash theme={"system"}
        sudo -u postgres pg_dumpall > all.sql
        ```
      </Tab>
    </Tabs>
  </Accordion>

  <Accordion title="3. Archive a directory" icon="file-zipper">
    It's convenient to pack a folder into a single compressed file and then download it:

    ```bash theme={"system"}
    tar -czf backup.tar.gz /var/www
    ```

    `-c` create, `-z` compress with gzip, `-f` file name. To unpack it again: `tar -xzf backup.tar.gz`.
  </Accordion>

  <Accordion title="4. Automate with cron" icon="clock">
    To have copies taken automatically on a schedule. On the server, open the task editor:

    ```bash theme={"system"}
    crontab -e
    ```

    Add a line — every day at 03:00, upload the directory to another server:

    ```bash theme={"system"}
    0 3 * * * rsync -az /var/www root@BACKUP_IP:/backups/$(date +\%F)
    ```

    The `%` sign in crontab is escaped as `\%`. For password-free login, set up an [SSH key](/en/vps/ssh-keys) to the receiving server in advance. Back up a database the same way: first `mysqldump`/`pg_dump` into a file, then `rsync` that file.
  </Accordion>

  <Accordion title="5. Copy the whole server" icon="hard-drive">
    Taking a full disk image through the panel isn't possible. But for a move or a full copy, it's enough to grab the important directories.

    Archive the key directories (sites, configs, database dumps):

    ```bash theme={"system"}
    tar -czf full.tar.gz /etc /var/www /home /root
    ```

    For migrating to another server, `rsync` is handier — it transfers the directories directly, skipping the intermediate archive:

    ```bash theme={"system"}
    rsync -avz /var/www root@NEW_IP:/var/www
    ```

    <Warning>
      `dd` for copying an entire disk is usually unavailable on a VPS and unsafe on a running system. Back up specific directories and database dumps, not "the whole disk".
    </Warning>
  </Accordion>
</AccordionGroup>

<Tip>
  Keep copies **off the server itself**: if it fails or gets reinstalled, a backup sitting next to the data will be gone along with it. Make copies on a schedule and test a restore at least once — deploy the dump and the archive on a test server and confirm the data reads correctly. An untested backup isn't a backup yet.
</Tip>

## Where to next

<CardGroup cols={2}>
  <Card title="Firewall" icon="shield-halved" href="/en/vps/firewall">
    Close off unnecessary ports — one of the steps in securing the server.
  </Card>

  <Card title="Server hardening" icon="lock" href="/en/vps/hardening">
    The full security checklist.
  </Card>
</CardGroup>
