public function doDownload($filename)
 {
     if (!auth_isadmin()) {
         throw new Exception('you must have AUTH_ADMIN permissions to download backup');
     }
     Backup::downloadFile($filename);
 }
 public function test_createBackupFile()
 {
     $res = Backup::createBackupFile(['conf'], true);
     $this->assertRegExp('/' . 'mybackup--' . date('Y-m-d_H-i-s') . '--\\w{7}\\.zip/', $res['filename']);
     $this->assertTrue($res['status']);
     $this->assertFileExists(sys_get_temp_dir() . '/' . $res['filename'], 'backup file was not created.');
     $this->assertTrue((new \ZipArchive())->open(sys_get_temp_dir() . '/' . $res['filename']), 'backup file is not valid zip archive');
 }
 protected function getBackupForm()
 {
     $form = new \Doku_Form(['id' => 'mybackup_form']);
     $form->startFieldset('Folders to Backup');
     foreach (Backup::allowedDirectories() as $dir => $desc) {
         $form->addElement(form_makeCheckboxField('dirs[]', $dir, "<b>{$dir}</b> {$desc}", null, null, ['checked' => 'checked']));
     }
     $form->endFieldset();
     $form->startFieldset('Options');
     $form->addElement('<b>Logging Output</b>');
     $form->addElement(form_makeCheckboxField('verbose', 1, 'verbose (it can be very long)'));
     $form->addElement('<br /><b>Archive Format</b>');
     foreach (Backup::supportedFormats() as $ext => $enabled) {
         $disabled = $enabled ? [] : ['disabled' => 'disabled'];
         $selected = $ext != 'zip' ? [] : ['checked' => 'checked'];
         $form->addElement(form_makeRadioField('archive_format', $ext, strtoupper($ext), 'archive_format', '', array_merge([], $selected, $disabled)));
     }
     $form->endFieldset();
     $form->addElement('<br />');
     //$form->addElement(form_makeButton('button', null, 'check size'));
     $form->addElement(form_makeButton('submit', null, 'backup now'));
     return $form;
 }