NFS Backup filenames and uid numbers

Christian Kratzer

New Member
Mar 14, 2016
2
0
1
57
Hi,

I am currently evaluating a proxmox Installation with a couple of VM.

My environment is proxmox on local zfs with disks in zvols. I am backing them up to nfs and am getting filenames like this:

vzdump-qemu-100-2016_03_14-09_53_32.log
vzdump-qemu-100-2016_03_14-09_53_32.vma.lzo
vzdump-qemu-101-2016_03_14-09_57_38.log
vzdump-qemu-101-2016_03_14-09_57_38.vma.lzo
vzdump-qemu-103-2016_03_14-10_02_19.log
vzdump-qemu-103-2016_03_14-10_02_19.vma.lzo​

That is the filenames only include the numeric vm id from the time of restore. I cannot find the VM name anywhere. If I move all of my about 50VM to proxmox with daily backups I am going to have a hard time matching the ID to the VM names.

What would be the best practice to handle this ?

Is there any way to get the VM name into the filenames ?

Should I backup each VM to a different directory ? If yes how ?

Also I found it slightly inconvenient that all backup files are being writting with a numeric uid of 4294967294 instead of something that is actually listed in /etc/passwd. Any way to change the user that is doing the NFS writing ?

Greetings
Christian Kratzer
CK Software GmbH
 
I ended up patching the default vzdump-hook-script.pl to rename the files after a successfull backup.

Greetings
Christian

--snipp--
ck@vm1:~$ diff -u vzdump-hook-script.pl.orig vzdump-hook-script.pl
--- vzdump-hook-script.pl.orig 2016-03-14 13:15:11.564097156 +0100
+++ vzdump-hook-script.pl 2016-03-14 20:45:29.699498488 +0100
@@ -6,6 +6,17 @@

print "HOOK: " . join (' ', @ARGV) . "\n";

+# get id2name mapping
+my $idmap={};
+open(QM,"/usr/sbin/qm list|");
+while(<QM>) {
+ next if /VMID/;
+ $_ =~ s/^\s+//;
+ my ($id,$name) = split(/\s+/,$_);
+ $idmap->{int($id)}=$name;
+}
+close(QM);
+
my $phase = shift;

if ($phase eq 'job-start' ||
@@ -51,12 +62,24 @@
if ($phase eq 'backup-end') {
#system ("scp $tarfile backup-host:/backup-dir") == 0 ||
# die "copy tar file to backup-host failed";
+ if (exists $idmap->{int($vmid)}) {
+ my $vmname = $idmap->{int($vmid)};
+ my $tarfile2 = $tarfile;
+ $tarfile2 =~ s/vzdump-qemu-$vmid/vzdump-qemu-$vmname/;
+ rename($tarfile,$tarfile2) || die ( "Error in renaming $tarfile to $tarfile2" );
+ }
}

# example: copy resulting log file to another host using scp
if ($phase eq 'log-end') {
#system ("scp $logfile backup-host:/backup-dir") == 0 ||
# die "copy log file to backup-host failed";
+ if (exists $idmap->{int($vmid)}) {
+ my $vmname = $idmap->{int($vmid)};
+ my $logfile2 = $logfile;
+ $logfile2 =~ s/vzdump-qemu-$vmid/vzdump-qemu-$vmname/;
+ rename($logfile,$logfile2) || die ( "Error in renaming $logfile to $logfile2" );
+ }
}

} else {
--snipp--