# Backing up data on dedicated servers and VPS

> Choose and set up backups for your VPS or dedicated server, whether managed or unmanaged, to protect sites and data.

Source: https://helpcenter.ruachost.com/vps/guides/backing-up-data-on-dedicated-servers-and-vps-in-ruachost/

Backups are critical for protecting your websites, applications, and databases from accidental deletion, corruption, or security incidents. On **Ruachost Dedicated Servers and VPS**, you have multiple options for creating and managing backups depending on whether your server is **managed** or **unmanaged**.

### Backup Options Overview

|  |  |
| --- | --- |
| Hosting Type | Backup Options |
| Managed VPS | Manual backups, cPanel backups, optional Ruachost Cloud Backup (powered by JetBackup) |
| Managed Dedicated Server | Manual backups, cPanel/WHM backups, optional Ruachost Cloud Backup |
| Unmanaged VPS / Dedicated Server | Manual backups, Bash scripts with cron jobs, remote backups (Amazon S3, Google Drive, rsync) |

> **Note:**
RAID mirroring (if enabled) only protects against hardware failure. It does not allow you to restore older versions of files. Always maintain your own backups.

## Backup Methods

### 1. Using WHM Backups (Managed Servers)

If your server includes **WebHost Manager (WHM)**:

- You can configure **full account backups** for all cPanel accounts.
- Backups can be stored locally or sent to a **remote destination** (FTP, SFTP, Amazon S3).
- WHM also allows scheduling (daily, weekly, monthly).

### 2. Using cPanel Backups

For individual accounts on VPS or Dedicated Servers with **cPanel**:

1. Log in to **cPanel**.
2. Go to **Files → Backup**.
3. Choose **Full Backup** (entire account) or **Partial Backup** (home directory, databases, email).
4. Download the backup to your computer or send it to a remote server.

### 3. Remote Cloud Backups

You can back up data to cloud storage providers:

- **Amazon S3**: Use s3cmd or AWS CLI to sync files.
- **Google Drive**: Use the gdrive utility to upload backups.
- **Other remote servers**: Use rsync or scp to transfer backups securely.

### 4. Bash Script + Cron Job (Unmanaged Servers)

For full control, you can create a custom backup script.

### Example Script

```bash
#!/bin/bash
destination_folder="/home/username/backup/$(date +%F)"
archive_file="backup-$(date +%H%M).tar.gz"

mkdir -p "$destination_folder"
/bin/tar --exclude='/home/username/backup' -czvf "$destination_folder/$archive_file" /home/username/public_html
```

- ### Save this as backup-cron.sh
- ### Make it executable

```bash
chmod +x /home/username/backup/backup-cron.sh
```

Schedule it with cron:

```bash
50 23 * * * /bin/sh /home/username/backup/backup-cron.sh
```

(Runs daily at 11:50 PM).

### 5. MySQL Database Backups

Use mysqldump to back up databases:

```bash
MySQL Database Backups
Use mysqldump to back up databases:
```

### 6. Remote Backups with rsync

To copy backups to another server:

```bash
rsync -avz /home/username/backup/ user@remote-server:/backup/
```
