Skip to content

Commit

Permalink
Run pre and post script when using Run command in Archives tab
Browse files Browse the repository at this point in the history
  • Loading branch information
ryecoaaron committed Apr 5, 2023
1 parent 84174b6 commit 1b32c4d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
openmediavault-borgbackup (6.4.4) UNRELEASED; urgency=medium

* Add option to change encrypted repo passphrase
* Run pre and post script when using Run command in Archives tab

-- OpenMediaVault Plugin Developers <plugins@omv-extras.org> Tue, 14 Mar 2023 18:08:51 -0500

Expand Down
21 changes: 21 additions & 0 deletions usr/share/openmediavault/engined/rpc/borgbackup.inc
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,16 @@ class OMVRpcServiceBorgBackup extends \OMV\Rpc\ServiceAbstract
// Create the background process.
return $this->execBgProc(function($bgStatusFilename, $bgOutputFilename)
use ($archive, $context, $repo) {
// prescript
$prescript = $archive->get('prescript');
if (strlen($prescript) > 1) {
$cmd = new \OMV\System\Process($prescript);
$cmd->setEnvFromFile($this->envFile . $archive->get('reporef'));
$cmd->setRedirect2to1();
$cmdLine = $cmd->getCommandLine();
$this->exec($cmdLine, $output, $bgOutputFilename);
}
// borg command
$cmdArgs = [];
$cmdArgs[] = $this->getProgram;
$cmdArgs[] = 'create';
Expand Down Expand Up @@ -512,6 +522,17 @@ class OMVRpcServiceBorgBackup extends \OMV\Rpc\ServiceAbstract
$this->writeBgProcOutput($bgOutputFilename, sprintf('Command: %s', $cmdLine));
$this->writeBgProcOutput($bgOutputFilename, PHP_EOL.PHP_EOL);
$this->exec($cmdLine, $output, $bgOutputFilename);
// post script
$postscript = $archive->get('postscript');
if (strlen($postscript) > 1) {
$cmd = new \OMV\System\Process($postscript);
$cmd->setEnvFromFile($this->envFile . $archive->get('reporef'));
$cmd->setRedirect2to1();
$cmdLine = $cmd->getCommandLine();
$this->writeBgProcOutput($bgOutputFilename, PHP_EOL.PHP_EOL);
$this->exec($cmdLine, $output, $bgOutputFilename);
}
// return
return $output;
}
);
Expand Down

0 comments on commit 1b32c4d

Please sign in to comment.