-
Notifications
You must be signed in to change notification settings - Fork 3
/
CronjobDatabaseBackup.module
630 lines (569 loc) · 22.9 KB
/
CronjobDatabaseBackup.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
<?php
/**
* ProcessWire Module Cronjob Database Backup
*
* @author kixe (Christoph Thelen) 2014/11/05
* @license Licensed under GNU/GPL v3
* @link https://processwire.com/talk/topic/8207-cronjob-database-backup/
* @version 1.2.4
*
* @since 1.1.5 added CTA Button to ProcessDatabaseBackups page (edit backups) 2016/11/28
* @since 1.1.6 fixed bug trigger backup by any user if time interval is selected. Added option to trigger backup on users login 2019/08/10
* @since 1.1.7 added option to export structure without data for specified tables #2 thanks to @philippdaun 2019/10/26
* @since 1.1.8 added option to automatically add newly created fields to an individual selection of tables 2019/10/26
* @since 1.1.9 added option select/ deselect all tables in one click for individual selection of tables 2019/10/27
* @since 1.2.0 fixed bug: backup property not set if backup trigger is disabled (cycle=0) 2019/10/28
* @since 1.2.1 fixed bug: load assets (js) only in Module Edit UI 2020/03/20
* @since 1.2.2 fixed bug: custom storage path not set 2020/04/20
* @since 1.2.3 added functionality to protect files by stopword used in name or description 2020/04/20
* @since 1.2.4 moved check if cycle is set after setting custom path to make available custom path for external trigger 2020/05/01
*
* some code taken from Ryans Module Database Backups (Thanks!)
*
* Database Backups
* ProcessWire 2.x, 3.x
* Copyright (C) 2014 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
*
* http://processwire.com
*
*/
class CronjobDatabaseBackup extends Process implements ConfigurableModule {
public static function getModuleInfo() {
$infoArray = array(
'title' => __('Cronjob Database Backup'),
'version' => 124,
'summary' => __("Periodic automatic backup of the database. Set interval or trigger option in module settings."),
'autoload' => true,
'singular' => true,
'author' => 'kixe',
'href' => 'https://processwire.com/talk/topic/8207-cronjob-database-backup/',
'license' => 'GNU-GPLv3',
'permissions' => array('trigger-db-backup' => 'Trigger database backup when a user logs in or logs out (CronjobDatabaseBackup)'),
'hreflicense' => 'http://www.gnu.org/licenses/gpl-3.0.html',
'requires' => array('LazyCron','ProcessWire>=2.4.15'),
'icon' => 'database'
);
return $infoArray;
}
static public function getDefaultConfig() {
return array(
'cycle' => 'every4Weeks', // default set to 4 weeks
'max' => null,
'deadline' => null,
'backup_all' => 1,
'backup_name' => null,
'backup_fileinfo' => null,
'field_storage_path' => null,
'tables' => array(),
'tables_content' => array(),
'auto_add_new_fields' => 1,
'stopword' => 'protected'
);
}
public function __construct() {
foreach(self::getDefaultConfig() as $key => $value) {
$this->$key = $value;
}
}
protected $backup = null;
/**
*
* maximum number of allowed backup files
*/
const MAXFILES = 100;
/**
* Initialize
* hooks in Lazy Cron
* set interval of script execution here
* check syntax of hookable time functions in wire/modules/LazyCron.module
*
*/
public function init() {
// load assets (js) only in Module Edit UI
if ($this->wire('input')->get('name') == "$this") parent::init();
// add newly created fields if auto_add_new_fields is enabled
if ($this->auto_add_new_fields) {
$this->addHookAfter('Fieldtype::createField', function(HookEvent $event) {
$modules = $this->wire('modules');
if ($event->return) {
$newField = $event->arguments(0);
// Getting, modifying and saving module config data
$data = $modules->getConfig('CronjobDatabaseBackup');
$data['tables'][] = $newField->table;
$data['tables_content'][] = $newField->table;
$modules->saveConfig('CronjobDatabaseBackup', $data);
}
});
}
// remove deleted fields
$this->addHookAfter('Fieldtype::deleteField', function(HookEvent $event) {
$modules = $this->wire('modules');
if ($event->return) {
$delField = $event->arguments(0);
// Getting, modifying and saving module config data
$data = $modules->getConfig('CronjobDatabaseBackup');
$data['tables_content'] = array_diff($data['tables_content'], array($delField->table));
$data['tables'] = array_diff($data['tables'], array($delField->table));
$modules->saveConfig('CronjobDatabaseBackup', $data);
}
});
// hook to add checkbox to select/ deselect all
$this->addHookAfter('InputfieldCheckboxes::render', function(HookEvent $event) {
if ($event->object->forModule != 'CronjobDatabaseBackup') return;
$markup = $event->return;
$checkbox = '<label><input data-for=".'. $event->object->id . '" type="checkbox" class="uk-checkbox check" value="0"/> <strong class="pw-no-select">' . __('select/ deselect all') . '</strong></label>';
$event->return = $checkbox . $markup;
});
$this->backup = $this->wire('database')->backups(); // WireDatabaseBackup Class
$this->max = ($this->max && $this->max <= self::MAXFILES)?$this->max:self::MAXFILES;
$customPath = self::checkPath($this->wire('config')->paths->root.$this->field_storage_path);
if ($this->field_storage_path && $customPath) $this->backup->setPath($customPath);
if (!$this->cycle) return;
if ($this->cycle == 'loginTrigger') {
$this->addHookAfter("Session::loginSuccess", function($e) {
$user = $e->arguments[0];
if(!$user->hasPermission('trigger-db-backup')) return;
$this->cronBackup();
});
}
else if ($this->cycle == 'logoutTrigger') {
$this->addHookAfter("Session::logoutSuccess", function($e) {
$user = $e->arguments[0];
if(!$user->hasPermission('trigger-db-backup')) return;
$this->cronBackup();
});
}
else {
$this->addHook("LazyCron::{$this->cycle}", $this, 'cronBackup');
}
}
/**
* checks wether a path exists or not and is writable
* @return string|bool false|int 0
*
*/
public static function checkPath($path) {
if(!is_dir($path)) return false;
if(!is_writable($path)) return 0;
return $path;
}
/**
* made by Ryan
*
*/
protected function backupPath($short = false) {
$path = $this->backup->getPath();
if($short) $path = str_replace($this->wire('config')->paths->root, '/', $path);
return $path;
}
/**
* replaces placeholders for databasename (#), date function (%) and user properties ({})
*
* @param string $string
* @return string
*
*/
protected function renderInfoString($string) {
$string = str_replace('#',$this->wire('config')->dbName, $string);
if(preg_match('/^([^%]*)%?([^%]*)%?([^%]*)$/', $string, $matches)) $string = $matches[1].date($matches[2]).$matches[3];
$user = $this->wire('user');
return wirePopulateStringTags($string, $user);
}
/**
*
* @return string filename .sql
* @see renderInfoString
*
*/
protected function ___backupFilename() {
$filename = $this->backup_name? $this->backup_name:$this->wire('config')->dbName;
$filename = $this->renderInfoString($filename);
$_filename = $filename;
$filename .= '.sql';
if(preg_match('/^(.+)-(\d+)$/', $_filename, $matches)) {
$_filename = $matches[1];
$n = $matches[2];
} else {
$n = 0;
}
while(file_exists($this->backupPath() . $filename)) {
$filename = $_filename . "-" . (++$n) . ".sql";
}
return $filename;
}
/**
*
* @return string
* @see renderInfoString
*
*/
protected function ___backupFileinfo() {
if (!$this->backup_fileinfo) return 'backup made by CronjobDatabaseBackup';
return $this->renderInfoString($this->backup_fileinfo);
}
/**
*
*
*/
public function cronBackup() {
$allTables = $this->backup->getAllTables();
$database = $this->wire('database');
$options = array(
'filename' => $this->backupFilename(),
'description' => $this->backupFileinfo(),
'maxSeconds' => 120
);
if(!$this->backup_all && $this->tables) {
// backup only selected tables
$options['tables'] = $this->tables;
// exclude table data from export for all selected tables
if (empty($this->tables_content)) $options['excludeExportTables'] = $this->tables;
// exclude table data from export for some of the selected tables
else {
$options['excludeExportTables'] = array();
foreach($this->tables as $table) {
if (in_array($table, $this->tables_content)) continue;
$options['excludeExportTables'][] = $table;
}
}
}
ignore_user_abort(true);
$file = $this->backup->backup($options);
$message = "Saved db-backup - PATH[$file]";
$this->message($message,Notice::logOnly);
// delete odd backups if deadline (date) or max (files)
if ($this->deadline || $this->max <= $this->getAll()) {
$removed = count($this->clean($this->max,strtotime("-{$this->deadline}")));
$message = "Deleted %d backup%s";
$this->message(sprintf($message,$removed,($removed>1)?'s':''),Notice::logOnly);
}
}
/**
* count backups (type sql)
* @return int|array
*
*/
protected function getAll($array = false) {
$path = $this->backupPath();
$files = scandir($path);
if(!count($files)) {
if ($array) return array('total' => 0, 'protected' => 0);
return 0;
}
$all = 0;
$protected = 0;
foreach ($files as $file) {
if (strrchr($file,'.') != '.sql') continue;
if ($array && $this->stopword) {
if (strpos($file, $this->stopword) !== false) {
$protected++;
continue;
}
$info = $this->backup->getFileInfo($file);
if (!empty($info) && $info['description'] && strpos($info['description'], $this->stopword) !== false) {
$protected++;
continue;
}
}
$all++;
}
if ($array) return array('total' => $all + $protected, 'protected' => $protected);
return $all + $protected;
}
/**
* get last backups
* files with stopword in its name or description will be ignored
*
* @param int $size
* @param int $deadline (unix timestamp)
* @return array/ bool
*
*/
protected function keep($size = 1, $deadline = null) {
$path = $this->backupPath();
$files = scandir($path);
if(!count($files)) return false;
foreach ($files as $file) {
if (strrchr($file,'.') != '.sql') continue;
if ($this->stopword) {
if (strpos($file, $this->stopword) !== false) continue;
$info = $this->backup->getFileInfo($file);
if (!empty($info) && $info['description'] && strpos($info['description'], $this->stopword) !== false) continue;
}
$date = filemtime($path.$file);
if($deadline && $date < $deadline) continue;
$last[$file] = $date;
}
arsort($last);
$last = array_keys($last);
if (!count($last)) return false;
return array_slice($last,0,$size);
}
/**
* clean backup directory
* files with stopword in its name or description will be ignored @see keep()
*
* @param int $size
* @param int $deadline (unix timestamp)
* @return array
*
*/
protected function clean($size = 1, $deadline = null) {
if (!$this->keep()) return array();
$path = $this->backupPath();
$cleaned = array();
$error_message = $this->_("Removing %1s from %2s failed!");
$keep = $this->keep($size, $deadline);
foreach(new DirectoryIterator($path) as $backup) {
if ($backup->getExtension() != 'sql') continue;
$backup = $backup->getFilename();
if (in_array($backup, $keep)) continue;
if (strpos($backup, $this->stopword) !== false) continue;
$info = $this->backup->getFileInfo($backup);
if (!empty($info) && $info['description'] && strpos($info['description'], $this->stopword) !== false) continue;
if (unlink($path.$backup)) {
$cleaned[] = $backup;
continue;
}
else $this->error(sprintf($error_message,$backup,$path));
}
return $cleaned;
}
/**
* module settings
*
*/
static public function getModuleConfigInputfields(array $data) {
$modules = wire('modules');
$database = wire('database');
$config = wire('config');
$cleaner = $modules->get('CronjobDatabaseBackup');
if(wire('input')->post->cleanup) {
$removed = $cleaner->clean(wire('input')->post->cleanup);
$message = __("%d backups deleted successfully");
if (!count($removed)) $cleaner->message( __('Nothing to clean in').' '.$cleaner->backupPath(true));
else $cleaner->message(sprintf($message,count($removed)));
}
$fields = new InputfieldWrapper();
$defaults = self::getDefaultConfig();
$data = array_merge($defaults, $data);
$path = $cleaner->backupPath(true);
$numFiles = $cleaner->getAll(true);
$f = $modules->get("InputfieldMarkup");
$markupText = sprintf( __('%d backups are currently stored in folder %s.'), $numFiles['total'], $path);
if (!empty($numFiles['protected'])) $markupText .= '<br/>' . sprintf( __('%d of them are protected.'), $numFiles['protected']);
$f->markupText = "<strong>$markupText</strong>";
if($cleaner->getAll() && wire('modules')->isInstalled('ProcessDatabaseBackups')) {
if (empty($data['field_storage_path'])) {
$b = $modules->get('InputfieldButton');
$b->value = __('Edit Backups');
$b->icon = 'database';
$b->href = wire('pages')->get('process='.$modules->getModuleInfo('ProcessDatabaseBackups')['id'])->url;
$b->addClass('head_button_clone');
$f->markupText .= '<p>'.$b->render().'</p>';
} else {
$text = __('Notice: You cannot use ProcessDatabaseBackups to edit backups stored under a custom path.');
$f->markupText .= "<p class='description'>$text</p>";
}
}
$fields->add($f);
$fs = $modules->get('InputfieldFieldset');
$fs->label = __("Basic Settings");
$fs->collapsed = false;
$f = $modules->get("InputfieldSelect");
$f->attr('name', 'cycle');
$f->label = __("Backup Trigger");
$f->icon = 'refresh';
$f->description = __("Select a time interval for automated database backups or a trigger option when a user logs in or logs out.");
if ($data['cycle'] == 'loginTrigger') $f->notes = __("**IMPORTANT:** The cronjob to backup your database is triggered after successfull login of any user with 'trigger-db-backup' permission.");
else if ($data['cycle'] == 'logoutTrigger') $f->notes = __("**IMPORTANT:** The cronjob to backup your database is triggered after successfull logout of any user with 'trigger-db-backup' permission.");
$f->addOptions(array(
0 => __('never'),
// 'every30Seconds' => __('30 seconds'), // for development use
'everyHour' => __('1 hour'),
'every6Hours' => __('6 hours'),
'everyDay' => __('1 day'),
'every2Days' => __('2 days'),
'everyWeek' => __('1 week'),
'every2Weeks' => __('2 weeks'),
'every4Weeks' => __('4 weeks'),
'loginTrigger' => __('login trigger'),
'logoutTrigger' => __('logout trigger')
));
if(isset($_POST['cycle']) && $_POST['cycle'] != $data['cycle']) $f->message( __('Backup cycle interval changed to').' '.$_POST['cycle']);
$f->value = $data['cycle'];
$f->columnWidth = 33;
$fs->add($f);
$def = $config->dbName;
$f = $modules->get('InputfieldText');
$f->attr('name', 'backup_name');
$f->set('collapsed',$data['backup_name']?false:true);
$f->attr('pattern', '[A-Za-z0-9%#_-]*');
$f->set('required', false);
$f->icon = 'file-archive-o';
$f->label = __('Backup Name');
$f->description = __('This will be used as the backup filename. Extension .sql will be added automatically.');
$f->notes = __('If omitted the name of the database will be used (config). Format syntax: # placeholder for db-name. Escape date() format with surrounding %. Any $user property surrounded with curled brackets will be replaced by the corresponding value.If filename exists a unique filename will be generated: [filename]-[n].sql. Allowed types: A-Z, a-z, 0-9, #, %, dash and underscore');
$f->value = $data['backup_name'];
$f->columnWidth = 33;
$fs->add($f);
$f = $modules->get('InputfieldText');
$f->attr('name', 'backup_fileinfo');
$f->set('collapsed',$data['backup_fileinfo']?false:true);
$f->set('required', false);
$f->icon = 'info-circle';
$f->label = __('Backup Fileinfo');
$f->description = __('Define custom fileinfo string here.');
$f->notes = __('Format syntax: # placeholder for db-name. Escape date() format with surrounding %. Any $user property surrounded with curled brackets will be replaced by the corresponding value. Default: \'backup made by CronjobDatabaseBackup\'');
$f->value = $data['backup_fileinfo'];
$f->columnWidth = 33;
$fs->add($f);
// add to fieldset
$fields->add($fs);
$fs = $modules->get('InputfieldFieldset');
$fs->label = __("Automatic Cleanup");
$fs->collapsed = true;
$f = $modules->get('InputfieldInteger');
$f->attr('name', 'max');
$f->value = $data['max'];
$f->icon = 'signal';
$f->attr('min', 1);
$f->attr('max', self::MAXFILES);
$f->attr('type', 'number');
$f->set('collapsed',$data['max']?false:true);
$f->label = __('Maximum Number of Backups');
$f->description = __('How many backups do you want to keep in the storage?');
$notes = __("max value: %d (defined by constant MAXFILES)");
$f->notes = sprintf($notes,self::MAXFILES);
$f->columnWidth = 33;
$fs->add($f);
$f = $modules->get("InputfieldSelect");
$f->attr('name', 'deadline');
$f->label = __("Remove backups older than");
$f->icon = 'calendar';
$f->description = __("Choose a time interval after a backup will be deleted sustainably by the cronjob.");
$f->set('collapsed',$data['deadline']?false:true);
$f->addOptions(array(
null => __('never'),
//'1 minute' =>__('1 minute'), // for development use
'1 day' => __('1 day'),
'1 week' => __('1 week'),
'1 month' => __('1 month'),
'1 year' => __('1 year'),
));
$f->value = $data['deadline'];
$f->columnWidth = 34;
$fs->add($f);
$f = $modules->get('InputfieldText');
$f->attr('name', 'stopword');
$f->set('required', false);
$f->label = __('File protection string');
$f->description = __('Using this string in a backup file name or description protects this file from being deleted.');
$f->notes = __('Files can still be deleted manually, but are not affected by the cyclical cleaning by the cronjob.');
$f->value = $data['stopword'];
$f->columnWidth = 33;
$fs->add($f);
$fields->add($fs);
$def = str_replace($config->paths->root,'', $database->backups()->getPath());
$f = $modules->get('InputfieldText');
$f->attr('name', 'field_storage_path');
$f->set('collapsed',$data['field_storage_path']?false:true);
$f->set('required', false);
$f->icon = 'folder-open-o';
$f->label = __('Storage Path');
$f->description = __("Path to custom storage directory under root.");
$rp = $config->paths->root;
$f->textFormat = 4;
$f->notes = sprintf( __("Leave this blank for storage under default path: %s. Use the full path, with a **leading slash**, to specify a path above root."), "$rp**$def**");
// check path
if(!count($_POST) && $data['field_storage_path']) {
$p = '';
if (strpos($data['field_storage_path'], '/') !== 0) $p .= $rp;
$p .= $data['field_storage_path'];
if (!is_dir($p)) $f->error("Path doesn't exist! Default pass will be used.");
elseif (!is_writable($p)) $f->error("Path isn't writable! Default pass will be used.");
}
$f->value = $data['field_storage_path'];
$fields->add($f);
$f = $modules->get('InputfieldCheckbox');
$f->attr('name', 'backup_all');
$f->icon = 'cube';
$f->label = __('Backup all tables?');
$f->attr('checked', $data['backup_all'] ? 'checked' : '' );
$f->notes = $data['backup_all']? __('Uncheck to make an individual selection.') :
__('Check to disable the selection below.');
$f->set('collapsed',$data['backup_all']?false:true);
$fields->add($f);
$f = $modules->get('InputfieldCheckboxes');
$f->optionColumns = 3;
$f->attr('name', 'tables');
$f->set('forModule', 'CronjobDatabaseBackup'); // identifier for hook @see init
$f->icon = 'table';
$f->label = __('Export Tables');
$f->description = __('By default, the export will include all tables. If you only want certain tables to be included in the backup file, select them below.');
$allTables = $database->backups()->getAllTables();
foreach($allTables as $table) $f->addOption($table, $table);
$f->attr('value', $data['tables']?$data['tables']:$allTables);
$f->showIf = 'backup_all=0';
$fields->add($f);
$f = $modules->get('InputfieldCheckboxes');
$f->optionColumns = 3;
$f->attr('name', 'tables_content');
$f->set('forModule', 'CronjobDatabaseBackup'); // identifier for hook @see init
$f->icon = 'list-alt';
$f->label = __('Export Tables Content');
$f->description = __('By default, the export will include the data inside the tables you selected above. If you only want to backup the table structure without the data for some tables, unselect them below.');
$f->notes = __('This option can be useful for security sensitive data or the `sessions` table on sites with a lot of visitors. You can not export data without the structure. Therefore tables are not selectable if they are unchecked in the previous field.');
$allTables = $database->backups()->getAllTables();
if (empty($data['tables'])) {
$value = $allTables;
foreach($allTables as $table) $f->addOption($table, $table);
}
else {
foreach($allTables as $table) {
$options = array();
if (!in_array($table, $data['tables'])) {
if (in_array($table, $data['tables_content'])) {
$data['tables_content'] = array_diff($data['tables_content'], array($table));
}
$options = array('disabled' => 'disabled');
}
$f->addOption($table, $table, $options);
}
// we expect a minimum of data
$value = $data['tables_content']? $data['tables_content'] : $data['tables'];
}
$f->attr('value', $value);
$f->set('collapsed',false);
$f->showIf = 'backup_all=0';
$fields->add($f);
$f = $modules->get('InputfieldCheckbox');
$f->attr('name', 'auto_add_new_fields');
$f->icon = 'refresh';
$f->label = __('Automatically add newly created fields to the setup.');
$f->attr('checked', $data['auto_add_new_fields']? 'checked' : '' );
$f->notes = __('If the checkbox is cleared, a newly created field will not be part of an individual setup for backups done by this module until manually added (checked) in the previous fields.');
$f->set('collapsed',$data['auto_add_new_fields']?false:true);
$f->showIf = 'backup_all=0';
$fields->add($f);
$f = $modules->get('InputfieldInteger');
$f->attr('name', 'cleanup');
$f->attr('min', 1);
$f->attr('type', 'number');
$f->set('collapsed',true);
$f->icon = 'fire';
$f->label = __('Burn backups now');
$f->description = __('Select the number of files that are to remain in the storage directory.');
$f->notes = __("Save to execute the process");
$fields->add($f);
return $fields;
}
public function ___uninstall() {
$userpath = ($this->data['field_storage_path'])?"] and in [".trim($this->data['field_storage_path'],'/'):"";
$defpath = $this->backupPath(true);
$this->error(sprintf( __("Please note that maybe backup files remain in folder %s%s. If you don't want them there, please remove them manually."),$defpath,$userpath),Notice::warning);
if ($this->wire('modules')->isInstalled('ProcessDatabaseBackups')) $this->message( __("Module 'Process Database Backups' remains installed"));
parent::___uninstall();
}
}