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

# How to Back Up a Linux Server: What to Save and Which Tool

> Back up a Linux server by copying /etc, /home, /var/www and database dumps off the server with rsync, restic or rclone, on a schedule, and test the restore.

To back up a Linux server, copy your configuration (`/etc`), your data (`/home`, `/var/www`, `/srv`, `/root`) and a fresh database dump to storage that is **not on the same server**. Use `rsync` for a plain copy to another server, `restic` for encrypted versioned backups, or `rclone` for cloud storage. Run it daily from cron and test a restore.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Beginner to intermediate | 30–60 minutes to set up | Ubuntu, Debian, AlmaLinux, Rocky Linux, Fedora and other distributions | sudo, a second place to store backups |

## Before you start

* [Connect with SSH](https://help.freakhosting.com/portals/other/how-to-connect-to-a-linux-server-with-ssh.md) as a user with `sudo`. Root users can leave out `sudo`.
* Decide where backups go: another server, object storage (S3-compatible), or your own computer. A backup that lives only on the same disk disappears with that disk.
* On a VPS, you can also take full-disk backups in the panel. See [VPS Panel backups](https://help.freakhosting.com/portals/vps-panel/how-to-schedule-and-restore-backups.md). File-level backups below are a second, independent copy you control.

## What should I back up on a Linux server?

| What | Where it usually lives | Why |
| - | - | - |
| System and service configuration | `/etc` | nginx, Apache, SSH, firewall and cron settings |
| Websites and app files | `/var/www`, `/srv`, `/opt` | Your code and uploads |
| User data and scripts | `/home`, `/root` | Keys, scripts, game server files |
| Databases | A dump file, not the raw files | Raw MySQL/PostgreSQL files copied while running can be inconsistent |
| Docker data | Named volumes and your compose files | Containers can be recreated, volumes cannot |
| Scheduled tasks | `crontab -l` for each user, `/etc/cron.d` | Easy to forget |
| Installed packages | A package list | Speeds up rebuilding the server |

You do **not** need `/proc`, `/sys`, `/dev`, `/run`, `/tmp` or package caches. They are created at boot or can be downloaded again.

## What is the 3-2-1 backup rule?

Keep **3** copies of your data, on **2** different types of storage, with **1** copy off-site. For a server that usually means: the live data, a panel or snapshot backup, and an off-server copy (another server or cloud storage) that the server itself cannot delete.

## Which backup tool should I use?

| Tool | Best for | Encrypted | Versions | Guide |
| - | - | - | - | - |
| `rsync` | Fast copy to another Linux server over SSH | Only in transit (SSH) | Optional, with `--link-dest` | [rsync backups](https://help.freakhosting.com/portals/other/how-to-back-up-files-with-rsync.md) |
| `restic` | Versioned, deduplicated, encrypted backups to SFTP, S3 or local disk | Yes | Yes | [restic backups](https://help.freakhosting.com/portals/other/how-to-make-encrypted-backups-with-restic.md) |
| `rclone` | Copying to Google Drive, S3, Backblaze B2 and many other cloud services | With a crypt remote | With `--backup-dir` | [rclone backups](https://help.freakhosting.com/portals/other/how-to-back-up-to-cloud-storage-with-rclone.md) |
| `tar` | A single archive file you can download | No | One file per run | [tar and zip](https://help.freakhosting.com/portals/other/how-to-compress-and-extract-files-tar-zip.md) |

If you are unsure, start with **restic**: it encrypts, keeps old versions and only uploads changes.

## How to make a simple backup with tar

This makes one compressed archive. It is a good first step, but copy the file off the server afterwards.

**1. Create a backup folder**

```bash theme={null}
sudo mkdir -p /backup
```

**2. Dump your databases**

For MariaDB or MySQL:

```bash theme={null}
sudo mysqldump --all-databases --single-transaction | sudo tee /backup/all-databases.sql > /dev/null
```

`sudo tee` writes the file as root, because `/backup` belongs to root. See [back up MySQL databases](https://help.freakhosting.com/portals/other/how-to-back-up-and-restore-mysql-databases.md) for details and PostgreSQL.

**3. Save the package list and crontab**

```bash theme={null}
dpkg --get-selections | sudo tee /backup/packages.txt > /dev/null   # Ubuntu / Debian
rpm -qa | sudo tee /backup/packages.txt > /dev/null                  # AlmaLinux / Rocky / Fedora
sudo crontab -l | sudo tee /backup/root-crontab.txt > /dev/null
```

**4. Create the archive**

```bash theme={null}
sudo tar -czpf /backup/server-$(date +%F).tar.gz \
  --exclude=/var/www/example.com/cache \
  /etc /home /root /var/www /backup/all-databases.sql /backup/packages.txt /backup/root-crontab.txt
```

`-p` keeps file permissions. `$(date +%F)` adds today's date, for example `server-2026-11-04.tar.gz`. tar prints `Removing leading '/' from member names`; this is normal.

**5. Protect the archive**

The archive holds passwords and keys from `/etc` and your database. Make it readable only by your user, so you can download it:

```bash theme={null}
sudo chown alex: /backup/server-2026-11-04.tar.gz
chmod 600 /backup/server-2026-11-04.tar.gz
```

**6. Copy it off the server**

From your own computer:

```bash theme={null}
scp alex@203.0.113.10:/backup/server-2026-11-04.tar.gz .
```

See [copy files with scp and rsync](https://help.freakhosting.com/portals/other/how-to-copy-files-with-scp-and-rsync.md).

> [!WARNING]
>
> A backup file stored on `/backup` of the same server is lost if the disk fails, the server is rebuilt or an attacker deletes it. Always keep a copy somewhere else.

## How to run backups automatically

Put your backup commands in a script, for example `/usr/local/bin/backup.sh`, make it executable with `sudo chmod 700 /usr/local/bin/backup.sh`, then add it to root's crontab with `sudo crontab -e`:

```bash theme={null}
# Run the backup every day at 03:15
15 3 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1
```

> [!TIP]
>
> In a crontab line, `%` has a special meaning. If you put `date +%F` directly in the crontab instead of in a script, write it as `date +\%F`. See [schedule tasks with cron](https://help.freakhosting.com/portals/other/how-to-schedule-tasks-with-cron.md).

## How to check your backups work

A backup you have never restored is a guess. Once a month:

1. Restore one folder to a temporary location, for example `/tmp/restore-test`.
2. Open a few files and compare them with the live ones.
3. Import a database dump into a test database.
4. Check the backup log for errors and the date of the last successful run.

## Frequently asked questions

### How often should I back up my server?

Back up at least daily for anything that changes, such as websites, databases and game worlds. Configuration can be backed up less often, but backing it up with the rest costs very little.

### Are VPS panel backups enough?

They are a useful full-disk copy, but they are one copy in one place. Keep at least one more copy that you control, off the server. See [VPS Panel backups](https://help.freakhosting.com/portals/vps-panel/how-to-schedule-and-restore-backups.md) for what the panel backs up.

### Can I back up a running database by copying its files?

Not safely. Files copied while the database is writing can be inconsistent. Use `mysqldump`/`mariadb-dump` or `pg_dump`, then back up the dump file.

### Is RAID a backup?

No. RAID keeps a server running when a disk fails, but it copies deletions and corruption to every disk instantly. See [software RAID with mdadm](https://help.freakhosting.com/portals/other/how-to-check-and-manage-software-raid-with-mdadm.md).

### How do I back up a Windows server?

Use Windows Server Backup or a third-party tool. See [back up a Windows server](https://help.freakhosting.com/portals/other/how-to-back-up-a-windows-server.md).

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every guide in this section.

> [card] [Encrypted backups with restic](https://help.freakhosting.com/portals/other/how-to-make-encrypted-backups-with-restic.md)
>
> Versioned, encrypted, deduplicated.

> [card] [Back up with rsync](https://help.freakhosting.com/portals/other/how-to-back-up-files-with-rsync.md)
>
> Copy to another server over SSH.

> [card] [Back up to cloud storage](https://help.freakhosting.com/portals/other/how-to-back-up-to-cloud-storage-with-rclone.md)
>
> S3, Google Drive and more with rclone.

> [card] [Back up MySQL databases](https://help.freakhosting.com/portals/other/how-to-back-up-and-restore-mysql-databases.md)
>
> Dump and restore your databases.

> [card] [VPS Panel backups](https://help.freakhosting.com/portals/vps-panel/how-to-schedule-and-restore-backups.md)
>
> Full-disk backups and restores.

***

> [!NOTE]
>
> **Checked against the official [Ubuntu Server backup documentation](https://ubuntu.com/server/docs/how-to/backups/back-up-using-shell-scripts/)** on 4 November 2026; `tar`, `dpkg --get-selections` and the folder list tested on Ubuntu 24.04 LTS. Commands can differ on other distributions or releases.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


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