Getting filename of a single backup created with vzdump --dumpdir

Wouter Samaey

Well-Known Member
May 28, 2018
72
12
48
39
With vzdump 100 --dumpdir --mode stop I can dump a single VM to a dir, but how can I know the resulting filename of that dump?

The man page does not tell anything about the output of vzdump

This is to be used in a bash script, so it should be non-interactive.

I already know about the backup hook script, and am using this for some other stuff, so this should be for a separate script.
In the hook script I know the backup file is a variable, but I can't use this here.

Any thoughts?
 
hi,

the extension depends on the compression algorithm which is used, so it is used during the restore...

since you specify a --dumpdir can't you just ls and see the list of files??

vzdump files are named like vzdump-${GUESTTYPE}-${VMID}-${DATE}.${EXT}
where GUESTTYPE=qemu or lxc
VMID is the ID of VM/CT
DATE is the current date and ${EXT} is the extension (depends on the chosen algorithm, by default .tar if nothing is specified
 
I can do "ls" but what if the dir contains multiple files from different backups at different times?

Finding the right file is a pain:
- Use a regex for this? Tricky...
- Use the latest created file? Dangerous...

So maybe using --stdout > file.ext is the best solution?

I would need to hard code the extensions in the bash script, but that's easier to manage, I think.

The best solution would be for the vzdump command to output the filenames of the dumps created, but not sure if this is a thing that you'd want to develop?
 
you can use a specific extension with the --compress flag (check man vzdump) when you're running vzdump


to make sure it's the file you're looking for, maybe a dirty hack but you can run mktemp -d to create a random directory in /tmp and set your --dumpdir to that. that way the only archive in that directory will be the one you just made, and the script can move it somewhere else when it's done...

what's the script supposed to do anyway?
 
This helps yes. The random dir is a great idea.

What I'm trying to do is create a script that migrates VMs from an old Proxmox to a new Proxmox. They aren't in a cluster and I have mounted a dir from the new Proxmox on the old one, so I can dump straight to the new machine instead of dumping locally and then moving afterwards saving time.

I have dumped and timed the transfer using all 3 compression types (none, lzo and gzip - zdst isn't available on the old machine) and selected lzo as the fastest way to transfer. Upload speed is a limiting factor, but also gzip would take more time regardless of the smaller file size.

The script will shutdown everything, dump, re-create the VM on the other end, startup the VM, configure iptables on the old VM to re-route traffic etc in an automated fashion.

I could use the hook script, but that's already in use for backups and I prefer a script that I control separately.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!