Signed-off-by: Marco Gabriel <mgabr...@inett.de>
---
 PVE/API2/Backup.pm        |  6 ++++++
 PVE/VZDump.pm             | 19 ++++++++++++++++++-
 www/manager6/dc/Backup.js | 10 +++++++++-
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Backup.pm b/PVE/API2/Backup.pm
index 86377c0a..316d6800 100644
--- a/PVE/API2/Backup.pm
+++ b/PVE/API2/Backup.pm
@@ -100,6 +100,12 @@ __PACKAGE__->register_method({
                description => "Enable or disable the job.",
                default => '1',
            },
+           includename => {
+               type => 'boolean',
+               optional => 1,
+               description => "Add VM name to backup file",
+               default => '0',
+           },
        }),
     },
     returns => { type => 'null' },
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index a829a52e..f6d7bc61 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -620,10 +620,27 @@ sub exec_backup_task {
 
        my $vmtype = $plugin->type();
 
+       my $conf;
+       my $name;
+
+       if ($opts->{includename}) {
+               if ($vmtype eq 'lxc') {
+                       $conf = PVE::LXC::Config->load_config($vmid);
+                       $name = "-" . $conf->{hostname};
+               } elsif ($vmtype eq 'qemu') {
+                       $conf = PVE::QemuConfig->load_config($vmid);
+                       $name = "-" . $conf->{name};
+               } else {
+                       die "Unknown VM Type: '$vmtype'\n";
+               }
+       } else {
+               $name = "";
+       }
+
        my $tmplog = "$logdir/$vmtype-$vmid.log";
 
        my $bkname = "vzdump-$vmtype-$vmid";
-       my $basename = $bkname . strftime("-%Y_%m_%d-%H_%M_%S", localtime());
+       my $basename = $bkname . strftime("-%Y_%m_%d-%H_%M_%S", localtime()) . 
$name;
 
        my $maxfiles = $opts->{maxfiles};
 
diff --git a/www/manager6/dc/Backup.js b/www/manager6/dc/Backup.js
index 28275f01..53dbc7a4 100644
--- a/www/manager6/dc/Backup.js
+++ b/www/manager6/dc/Backup.js
@@ -186,7 +186,15 @@ Ext.define('PVE.dc.BackupEdit', {
                allowBlank: false
            },
            selModeField,
-           selPool
+           selPool,
+           {
+               xtype: 'proxmoxcheckbox',
+               fieldLabel: gettext('Include VM Name'),
+               name: 'includename',
+               uncheckedValue: 0,
+               defaultValue: 0,
+               checked: false
+           }
        ];
 
        var column2 = [
-- 
2.20.1

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to