---
title: "Kubernetes Backup with Velero | Hostman Docs"
description: "Complete guide to Velero for Kubernetes data protection. Learn how to configure S3 credentials, install Velero, create backups, restore clusters, and automate scheduled backups for reliable disaster recovery."
---

> For the complete documentation index for AI agents, see [llms.txt](https://hostman.com/llms.txt).

Velero is a tool for backing up, restoring, and migrating data in Kubernetes. It allows you to create backups, restore cluster states, and perform migrations between clusters.

To use Velero, you need to install the Velero CLI on your local machine and configure it in your Kubernetes cluster.

## Prerequisites

Before starting the installation, ensure you have:

-   Access to your Kubernetes cluster [configured](https://hostman.com/docs/kubernetes/connect-to-clusters/kubectl/) via `kubectl`.
-   An S3 bucket for storing backups. 

Create a separate namespace for Velero:

```shell
kubectl create namespace velero
```

## Creating an S3 Secret

To configure Velero's access to the S3 bucket, create a secret. Create a manifest file named `velero-credentials-secret.yaml` with the following content:

```yml
apiVersion: v1
kind: Secret
metadata:
  name: cloud-credentials
  namespace: velero
type: Opaque
stringData:
  cloud: |
    [default]
    aws_access_key_id=S3_Access_Key
    aws_secret_access_key=S3_Secret_Access_Key
```

Replace `S3_Access_Key` and `S3_Secret_Access_Key` with your S3 access credentials.

![Ccda87b0 981b 41db A72f Dd8785e459e0.png](https://content.hostman.com/assets/7846ed96-e927-4598-bab6-5e88b60cc6d8.png?width=1533&height=1233)

Apply the manifest:

```shell
kubectl apply -f velero-credentials-secret.yaml
```

Verify the secret creation:

```shell
kubectl describe secrets cloud-credentials -n velero
```

The `Data.cloud` value should not be empty.

## Installing Velero CLI

### Linux

Download the latest Velero release archive from the [official GitHub releases page](https://github.com/vmware-tanzu/velero/releases):

```shell
wget https://github.com/vmware-tanzu/velero/releases/download/v1.15.2/velero-v1.15.2-linux-amd64.tar.gz
```

Extract the archive:

```shell
tar -xvzf velero-v1.15.2-linux-amd64.tar.gz
```

Move the Velero binary to the `/usr/local/bin` directory:

```shell
sudo mv ./velero-v1.15.2-linux-amd64/velero /usr/local/bin/
```

### macOS

To install Velero on macOS, run:

```shell
brew install velero
```

### Windows

To install Velero on Windows using Chocolatey, run:

```shell
choco install velero
```

### Verify Installation

Check the installed version:

```shell
velero version
```

## Installing Velero in the Cluster

Create a `values.yaml` file with the minimum required configuration:

```yml
namespace:
  name: velero
  labels: {}

credentials:
  existingSecret: cloud-credentials

configuration:
  backupStorageLocation:
    - name: default
      provider: aws
      bucket: bucket_name
      default: true
      config:
        region: us-2
        s3ForcePathStyle: true
        s3Url: https://s3.hmstorage.net

  volumeSnapshotLocation:
    - name: default
      provider: aws
      config:
        region: us-2
initContainers:
  - name: velero-plugin-for-aws
    image: velero/velero-plugin-for-aws:v1.7.0
    volumeMounts:
      - mountPath: /target
        name: plugins
```

Parameter descriptions:

-   `backupStorageLocation`: Configures the backup storage.
-   `bucket`: The S3 bucket name.
-   `s3Url`: The Hostman S3 storage URL.
-   `initContainers`: Adds the required plugin for S3 integration.
-   `credentials.existingSecret`: Refers to the previously created `cloud-credentials` secret containing the S3 access keys.

### Via Dashboard

1.  Go to the **Kubernetes** section and click on the cluster.
2.  Navigate to the **Addons** tab and select **Velero**.
3.  Enable **Advanced setup** and upload the `values.yaml` file by clicking **Upload configuration from file**.
4.  Click **Install**.

![9b3c8b47 D00b 436b 804b 45455e420a6c](https://content.hostman.com/assets/84a300fe-2f1e-4d1c-8a04-7935eedcf2e2.png?width=1554&height=1093)

Wait for the installation to complete and check the pod status:

```shell
kubectl get pods -n velero
```

### Via Helm

You can install Velero using Helm.

1.  Add the Velero repository:
    

```shell
helm repo add velero https://vmware-tanzu.github.io/helm-charts
helm repo update
```

2.  Install Velero using the configuration file:
    

```shell
helm install velero velero/velero -f values.yaml --namespace velero
```

3.  Verify the installation:
    

```shell
kubectl get pods -n velero
```

The status of Velero pods should be `Running`.

## Usage

To demonstrate how Velero works, we will create a test deployment with Nginx and show the process of creating a backup, deleting resources, and then restoring the data.

### Creating a Backup

Create a deployment with Nginx in a separate namespace:

```shell
kubectl create namespace nginx-test
kubectl create deployment nginx --image=nginx -n nginx-test
```

Create a backup:

```shell
velero backup create nginx-backup --include-namespaces nginx-test
```

We specified the `--include-namespaces` parameter to back up the entire namespace. You can also specify other parameters when creating a backup:

-   `--include-resources`: Includes specific resources (e.g., `pods`, `services`).
-   `--exclude-resources`: Excludes specific resources.
-   `--ttl`: Sets the backup retention time (e.g., `10h15m0s`).

Check the backup status:

```shell
velero backup describe nginx-backup
```

### Restoring Data

Delete the test namespace:

```shell
kubectl delete namespace nginx-test
```

Restore resources from the backup:

```shell
velero restore create --from-backup nginx-backup
```

Ensure that the namespace and deployment have been restored:

```shell
kubectl get all -n nginx-test
```

## Managing Backup Schedules and Statuses

In addition to creating backups manually, Velero allows you to automate backup creation on a schedule. You can also manage existing backups.

### Configuring Automatic Backups

You can configure a schedule for regular backups. For example, to back up all namespaces every day at midnight:

```shell
velero schedule create task_name --schedule "0 0 * * *" --include-namespaces '*'
```

-   `--schedule "0 0 * * *"`: Cron format schedule (every day at 00:00).
-   `--include-namespaces '*'`: Includes all namespaces.

To create backups for a single namespace every hour:

```shell
velero schedule create task_name --schedule "0 * * * *" --include-namespaces my-namespace
```

Check the backup schedule with:

```shell
velero schedule get
```

If a scheduled task is no longer needed, delete it with:

```shell
velero schedule delete task_name
```

### Viewing and Managing Backups

List all existing backups:

```shell
velero backup get
```

To delete an old backup, use:

```shell
velero backup delete backup_name
```

To check backup details, including its status and resources:

```shell
velero backup describe backup_name --details
```

These features provide flexible backup management and allow data restoration whenever needed.
