# Backing up LIS or STS to a remote Backup server

Follow these steps to set up automatic backups to a remote Ubuntu machine:

### Step 1: Download the Script
Open a terminal on your Ubuntu machine and run the following command to download the backup setup script:

```bash
cd ~
wget -O remote-backup.sh https://raw.githubusercontent.com/deforay/vlsm/master/scripts/remote-backup.sh
```

### Step 2: Make the Script Executable

To allow the script to run, change its permissions using the following command:

```bash
sudo chmod u+x remote-backup.sh
```

### Step 3: Run the Script


Execute the script with superuser privileges to begin the setup process:

```bash
sudo ./remote-backup.sh
```
---
##### What the Script Does:

1. **Prompts for the Instance Name**:
   - Enter a unique name for your lab or instance (e.g., `lab1`, `centerA`).
   - The script will sanitize the name to ensure compatibility.

2. **Installs Required Tools**:
   - Ensures `rsync` is installed on your machine.

3. **Generates SSH Key**:
   - Creates an SSH key for secure communication with the backup server (if not already present).

4. **Prompts for Backup Server Details**:
   - Enter the **username** and **IP address or hostname** of the backup server.

5. **Verifies Connectivity**:
   - Tests the connection to the backup server.
   - If the connection fails, it will prompt you to re-enter the credentials until the connection succeeds.

6. **Copies SSH Key**:
   - Automatically transfers the SSH key to the backup server to enable passwordless communication.

7. **Creates Backup Script**:
   - Sets up a script to back up `/var/www/vlsm` to the backup server.

8. **Schedules Backups**:
   - Configures automatic backups to run every 6 hours and on reboot using cron jobs.