helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

Creating backups using the single helm chart

Open WyriHaximus opened this issue 5 years ago • 11 comments

Been using victoriametrics for a few months now and it's absolutely a breeze to set up with these helm charts. But what I'm missing here is a way to back up to a network drive (cifs/smb in my case). Now I'd gladly add this to the helm chart with a cronjob. But up on researching this I found that the only way it seems to backup is using direct access to the data dir. Is there a way to backup metrics over TCP/UDP from another pod?

WyriHaximus avatar Jul 18 '20 18:07 WyriHaximus

As I know, the vmbackup ma run as a sidecar in the same pod as single-node VictoriaMetrics or vmstorage component in cluster version. cc'ing @tenmozes for more input

valyala avatar Jul 20 '20 18:07 valyala

actually vmbackup is a cli command which can not be executed like sidecar, need to demonize it and add scheduling this is main reason why it doesn't exist in helm chart

tenmozes avatar Jul 21 '20 06:07 tenmozes

actually vmbackup is a cli command which can not be executed like sidecar, need to demonize it and add scheduling this is main reason why it doesn't exist in helm chart

Yeah this is why I was thinking about using a cronjob for it. But if it only works with file access to the data that is going to be a bit harder

WyriHaximus avatar Jul 21 '20 10:07 WyriHaximus

I think it should be possible, I am currently working on patching the helm chart to add a sidecar container to the server pod that would run vmbackup instance managed by crond.

Looks like vmbackup image is based off alpine, and according to

https://gist.github.com/AntonFriberg/692eb1a95d61aa001dbb4ab5ce00d291

I only need to put an incremental vmbackup invocation into /etc/periodic/hourly that would invoke a snapshot-creating request via curl against localhost (btw, would be a bit less moving pieces if vmbackup would be able to send the "create snapshot" request itself), and then put that snapshot into the /latest directory. And then a daily invocation of vmbackup would copy the /latest directory a daily snapshot, that script would go into /etc/periodic/daily.

immerrr avatar Feb 11 '21 13:02 immerrr

Regarding "btw, would be a bit less moving pieces if vmbackup would be able to send the "create snapshot" request itself": vmbackup has the option "-snapshot.createURL string" to do exactly this.

ulikl avatar Feb 11 '21 15:02 ulikl

@ulikl ah, thank you, good to know!

does it mean that when i pass a -snapshotName=<local-snapshot> to vmbackup with -snapshot.createURL, it will create a snapshot automatically?

immerrr avatar Feb 11 '21 16:02 immerrr

So does this mean we wouldn't have to go with the sidecar route and could go with a pod (cronjob) instead? Is -snapshot.createURL the URL of VM?

WyriHaximus avatar Feb 11 '21 18:02 WyriHaximus

I think you still need a sidecar to access the volume where snapshots are created.

immerrr avatar Feb 11 '21 18:02 immerrr

Ok wait, then how should I read:

 -snapshot.createURL string
    	VictoriaMetrics create snapshot url. When this is given a snapshot will automatically be created during backup. Example: http://victoriametrics:8428/snaphsot/create

(From: https://victoriametrics.github.io/vmbackup.html )

I might be missing some VM knowledge how snapshots work here tbh :D

WyriHaximus avatar Feb 11 '21 19:02 WyriHaximus

This is the URL on the VictoriaMetrics (vmstorage) instance itself, that would trigger a creation of a snapshot in its corresponding data directory. If vmbackup has access to that directory, it can then send the generated file wherever you point it (S3, GCP, etc).

immerrr avatar Feb 11 '21 19:02 immerrr

Ahhhh ok check :+1: . Yeah then it's going to be really hard not using a sidecar

WyriHaximus avatar Feb 11 '21 19:02 WyriHaximus