> For the complete documentation index, see [llms.txt](https://docs.groundcover.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.groundcover.com/~/revisions/ETrLpNk6KtHjyaVUTLoE/use-groundcover/backup-and-restore-metrics.md).

# Backup & Restore Metrics

groundcover uses [VictoriaMetrics](https://docs.victoriametrics.com/) as its underlying metrics storage solution. As such, groundcover integrates seamlessly with VictoriaMetrics [vmbackup](https://docs.victoriametrics.com/vmbackup.html) and [vmrestore](https://docs.victoriametrics.com/vmrestore.html) tools.

## Doing incremental backups

* [Install vmutils ](https://github.com/VictoriaMetrics/VictoriaMetrics/releases)
* port-forward groundcover's VictoriaMetrics service object

```bash
kubectl get svc -n groundcover | grep "victoria-metrics"
# Identify the victoria-metrics service object name
kubectl port-forward svc/{victoria-metrics-service-object-name} \
-n groundcover 8428:8428
```

* Run the `vmbackup` utility, in this example we'll set the destination to an AWS S3 bucket, [but more providers are supported](https://docs.victoriametrics.com/vmbackup.html#supported-storage-types)

```bash
./vmbackup -credsFilePath={aws credentials path} \
-storageDataPath=</path/to/victoria-metrics-data> \
-snapshot.createURL=http://localhost:8428/snapshot/create \
-dst=s3://<bucket>/<path/to/backup>
```

{% hint style="info" %}
vmbackup automatically uses incremental backup strategy if the destination contains an existing backup
{% endhint %}

## Restoring from backup

* Scale down VictoriaMetrics statefulSet (VictoriaMetrics must be offline during restorations)

```bash
kubectl scale sts {release name}-victoria-metrics --replicas=0
```

* Get the VictoriaMetrics PVC name

```bash
kubectl get pvc -n groundcover | grep victoria-metrics
```

* Create the following Kubernetes Job manifest `vm-restore.yaml`&#x20;

{% hint style="info" %}
Make sure you replace {VICTORIA METRICS PVC NAME} with the fetched pvc name
{% endhint %}

<pre class="language-yaml"><code class="lang-yaml">apiVersion: v1
kind: ServiceAccount
metadata:
  name: vm-restore
  annotations:
    eks.amazonaws.com/role-arn: XXXXX # role with permissions to write to the bucket
---
<strong>apiVersion: batch/v1
</strong>kind: Job
metadata:
  name: vm-restore
spec:
  ttlSecondsAfterFinished: 600
  template:
    spec:
      serviceAccountName: vm-restore
      restartPolicy: OnFailure
      volumes:
      - name: vmstorage-volume
        persistentVolumeClaim:
          claimName: "{VICTORIA METRICS PVC NAME}"
      containers:
      - name: vm-restore
        image: victoriametrics/vmrestore
        imagePullPolicy: IfNotPresent
        volumeMounts:
        - mountPath: /storage
          name: vmstorage-volume
        command:
        - /bin/sh
        - -c
        - /vmrestore-prod -src=s3://&#x3C;bucket>/&#x3C;path/to/backup> -storageDataPath=/storage
</code></pre>

* Deploy the job and wait for completion

```bash
kubectl apply -f vm-restore.yaml -n groundcover
```

* Once completed, scale up groundcover's VictoriaMetrics instance

```
kubectl scale sts {release name}-victoria-metrics --replicas=1
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.groundcover.com/~/revisions/ETrLpNk6KtHjyaVUTLoE/use-groundcover/backup-and-restore-metrics.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
