[pve-devel] [PATCH pve-manager 1/1] vzdump: added "includename" option

2019-11-13 Thread Marco Gabriel
Signed-off-by: Marco Gabriel 
---
 PVE/VZDump/Common.pm | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/PVE/VZDump/Common.pm b/PVE/VZDump/Common.pm
index 4789a50..0a70b0c 100644
--- a/PVE/VZDump/Common.pm
+++ b/PVE/VZDump/Common.pm
@@ -213,6 +213,12 @@ my $confdesc = {
type => 'string',
description => 'Backup all known guest systems included in the 
specified pool.',
optional => 1,
+},
+includename => {
+   type => 'boolean',
+   description => 'Include name of VM in backup file name.',
+   optional => 1,
+   default => 0,
 }
 };
 
-- 
2.20.1

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


[pve-devel] [PATCH pve-manager 1/1] vzdump: added "includename" option which adds the name or hostname of a vm or container to a backup filename

2019-11-13 Thread Marco Gabriel
Signed-off-by: Marco Gabriel 
---
 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