]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/window/Backup.js
1 Ext
.define('PVE.window.Backup', {
2 extend
: 'Ext.window.Window',
6 initComponent: function() {
10 throw "no node name specified";
14 throw "no VM ID specified";
18 throw "no VM type specified";
21 let compressionSelector
= Ext
.create('PVE.form.BackupCompressionSelector', {
24 fieldLabel
: gettext('Compression'),
27 let modeSelector
= Ext
.create('PVE.form.BackupModeSelector', {
28 fieldLabel
: gettext('Mode'),
33 let mailtoField
= Ext
.create('Ext.form.field.Text', {
34 fieldLabel
: gettext('Send email to'),
36 emptyText
: Proxmox
.Utils
.noneText
,
39 let notificationModeSelector
= Ext
.create({
40 xtype
: 'proxmoxKVComboBox',
42 ['auto', gettext('Auto')],
43 ['legacy-sendmail', gettext('Email (legacy)')],
44 ['notification-system', gettext('Notification system')],
46 fieldLabel
: gettext('Notification mode'),
47 name
: 'notification-mode',
50 change: function(field
, value
) {
51 mailtoField
.setDisabled(value
=== 'notification-system');
57 ['keep-last', gettext('Keep Last')],
58 ['keep-hourly', gettext('Keep Hourly')],
59 ['keep-daily', gettext('Keep Daily')],
60 ['keep-weekly', gettext('Keep Weekly')],
61 ['keep-monthly', gettext('Keep Monthly')],
62 ['keep-yearly', gettext('Keep Yearly')],
65 let pruneSettings
= keepNames
.map(
66 name
=> Ext
.create('Ext.form.field.Display', {
73 let removeCheckbox
= Ext
.create('Proxmox.form.Checkbox', {
78 fieldLabel
: gettext('Prune'),
81 'data-qtip': gettext('Prune older backups afterwards'),
83 handler: function(checkbox
, value
) {
84 pruneSettings
.forEach(field
=> field
.setHidden(!value
));
85 me
.down('label[name="pruneLabel"]').setHidden(!value
);
89 let initialDefaults
= false;
91 var storagesel
= Ext
.create('PVE.form.StorageSelector', {
92 nodename
: me
.nodename
,
94 fieldLabel
: gettext('Storage'),
95 storageContent
: 'backup',
98 change: function(f
, v
) {
99 if (!initialDefaults
) {
100 me
.setLoading(false);
103 if (v
=== null || v
=== undefined || v
=== '') {
107 let store
= f
.getStore();
108 let rec
= store
.findRecord('storage', v
, 0, false, true, true);
110 if (rec
&& rec
.data
&& rec
.data
.type
=== 'pbs') {
111 compressionSelector
.setValue('zstd');
112 compressionSelector
.setDisabled(true);
113 } else if (!compressionSelector
.getEditable()) {
114 compressionSelector
.setDisabled(false);
117 Proxmox
.Utils
.API2Request({
118 url
: `/nodes/${me.nodename}/vzdump/defaults`,
124 success: function(response
, opts
) {
125 const data
= response
.result
.data
;
127 if (!initialDefaults
&& data
.mailto
!== undefined) {
128 mailtoField
.setValue(data
.mailto
);
130 if (!initialDefaults
&& data
['notification-mode'] !== undefined) {
131 notificationModeSelector
.setValue(data
['notification-mode']);
133 if (!initialDefaults
&& data
.mode
!== undefined) {
134 modeSelector
.setValue(data
.mode
);
136 if (!initialDefaults
&& (data
['notes-template'] ?? false)) {
137 me
.down('field[name=notes-template]').setValue(
138 PVE
.Utils
.unEscapeNotesTemplate(data
['notes-template']),
142 initialDefaults
= true;
144 // always update storage dependent properties
145 if (data
['prune-backups'] !== undefined) {
146 const keepParams
= PVE
.Parser
.parsePropertyString(
147 data
["prune-backups"],
149 if (!keepParams
['keep-all']) {
150 removeCheckbox
.setHidden(false);
151 pruneSettings
.forEach(function(field
) {
152 const keep
= keepParams
[field
.name
];
154 field
.setValue(keep
);
163 // no defaults or keep-all=1
164 removeCheckbox
.setHidden(true);
165 removeCheckbox
.setValue(false);
166 pruneSettings
.forEach(field
=> field
.reset());
168 failure: function(response
, opts
) {
169 initialDefaults
= true;
171 removeCheckbox
.setHidden(true);
172 removeCheckbox
.setValue(false);
173 pruneSettings
.forEach(field
=> field
.reset());
175 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
182 let protectedCheckbox
= Ext
.create('Proxmox.form.Checkbox', {
186 fieldLabel
: gettext('Protected'),
189 me
.formPanel
= Ext
.create('Proxmox.panel.InputPanel', {
199 notificationModeSelector
,
205 xtype
: 'textareafield',
206 name
: 'notes-template',
207 fieldLabel
: gettext('Notes'),
209 value
: '{{guestname}}',
215 'line-height': '1.5em',
217 html
: Ext
.String
.format(
218 gettext('Possible template variables are: {0}'),
219 PVE
.Utils
.notesTemplateVars
.map(v
=> `<code>{{${v}}}</code>`).join(', '),
225 text
: gettext('Storage Retention Configuration') + ':',
264 var submitBtn
= Ext
.create('Ext.Button', {
265 text
: gettext('Backup'),
266 handler: function() {
267 var storage
= storagesel
.getValue();
268 let values
= me
.formPanel
.getValues();
273 remove
: values
.remove
,
277 params
.mailto
= values
.mailto
;
280 if (values
['notification-mode']) {
281 params
['notification-mode'] = values
['notification-mode'];
284 if (values
.compress
) {
285 params
.compress
= values
.compress
;
288 if (values
.protected) {
289 params
.protected = values
.protected;
292 if (values
['notes-template']) {
293 params
['notes-template'] = PVE
.Utils
.escapeNotesTemplate(
294 values
['notes-template']);
297 Proxmox
.Utils
.API2Request({
298 url
: '/nodes/' + me
.nodename
+ '/vzdump',
301 failure: function(response
, opts
) {
302 Ext
.Msg
.alert('Error', response
.htmlStatus
);
304 success: function(response
, options
) {
305 // close later so we reload the grid
306 // after the task has completed
309 var upid
= response
.result
.data
;
311 var win
= Ext
.create('Proxmox.window.TaskViewer', {
325 var helpBtn
= Ext
.create('Proxmox.button.Help', {
326 onlineHelp
: 'chapter_vzdump',
327 listenToGlobalEvent
: false,
331 var title
= gettext('Backup') + " " +
332 (me
.vmtype
=== 'lxc' ? "CT" : "VM") +
341 items
: [me
.formPanel
],
342 buttons
: [helpBtn
, '->', submitBtn
],
344 afterrender: function() {
345 /// cleared within the storage selector's change listener
346 me
.setLoading(gettext('Please wait...'));
347 storagesel
.setValue(me
.storage
);