Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
andrelopez committed Jun 24, 2020
2 parents c559b65 + bbae236 commit eb3cfa4
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 68 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Enupal Backup Changelog

## 1.5.0 - 2020.06.24

> {tip} This release fixes an issue with Amazon SQS queue service, if you have scheduled backups via Webhook you need to add an additional cronjob, instructions under Enupal Backup -> Settings -> Schedule [docs](https://docs.enupal.com/enupal-backup/schedule/webhook.html). We recommend update to this version as the performance is improved. Enjoy!
### Fixed
- Fixed issue with Amazon SQS queue service

### Removed
- Removed "Run job in background" setting

## 1.4.0 - 2020.03.24
### Added
- Added support for Craft CMS 3.4.x
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<a href="https://enupal.com/craft-plugins/enupal-backup/docs/" target="_blank">
<a href="https://docs.enupal.com/enupal-backup/" target="_blank">
<img width="212" height="212" src="https://enupal.com/assets/docs/backup-icon.svg" alt="Enupal Backup"></a>
</p>

Expand Down Expand Up @@ -40,7 +40,7 @@ Fully integrated Backup solution for Craft CMS

## Documentation

https://enupal.com/craft-plugins/enupal-backup/docs/
https://docs.enupal.com/enupal-backup/

## Enupal Backup Support

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "enupal/backup",
"description": "Fully integrated Backup solution for Craft CMS",
"type": "craft-plugin",
"version": "1.4.0",
"version": "1.5.0",
"keywords": [
"craft",
"cms",
Expand Down
52 changes: 1 addition & 51 deletions src/services/Backups.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,58 +85,9 @@ public function executeEnupalBackup()
// Add our CreateBackup job to the queue
Craft::$app->queue->push(new CreateBackup());

if (Backup::$app->settings->isWindows()) {
if (Craft::$app->getRequest()->isSiteRequest) {
Craft::$app->getQueue()->run();
$response['message'] = 'running';
}
} else {
// if is Linux try to call queue/run
if ($settings->runJobInBackground){
$this->runQueueInBackground();
}else{
Craft::$app->getQueue()->run();
}
$response['message'] = 'running';
}

return $response;
}

/**
* @return bool
*/
public function runQueueInBackground()
{
$success = false;
$settings = Backup::$app->settings->getSettings();
if (!Backup::$app->settings->isWindows()) {
$shellCommand = new ShellCommand();
// We have better error messages with exec
if (function_exists('exec') && $settings->useExec) {
$shellCommand->captureStdErr = false;
Craft::info('useExec is enabled on running the queue on background', __METHOD__);
$shellCommand->useExec = true;
}
$craftPath = CRAFT_BASE_PATH;
$phpPath = Backup::$app->backups->getPhpPath();

$command = 'cd' .
' ' . $craftPath;
$command .= ' && ' . $phpPath .
' ./craft' .
' queue/run';
//$command .= ' > /dev/null 2>&1 &';

Craft::info('Queue Command: ' . $command, __METHOD__);
$shellCommand->setCommand($command);
$success = $shellCommand->execute();
Craft::info('Queue Command Result: ' . $success, __METHOD__);
}

return $success;
}

/**
* @return array
*/
Expand Down Expand Up @@ -344,7 +295,7 @@ public function installDefaultValues()

$primarySiteUrl = Craft::getAlias($primarySite['baseUrl']);

$settings['primarySiteUrl'] = $primarySiteUrl;
$settings['primarySiteUrl'] = Craft::parseEnv(Craft::getAlias(rtrim(trim($primarySiteUrl), "/")));;

Craft::$app->getPlugins()->savePluginSettings(Backup::getInstance(), $settings);
}
Expand Down Expand Up @@ -493,7 +444,6 @@ public function processPendingBackups()
if ($pendingBackups) {
$checkPendingBackups->pendingBackups = $pendingBackups;
Craft::$app->queue->push($checkPendingBackups);
Craft::$app->queue->run();
}
}

Expand Down
12 changes: 0 additions & 12 deletions src/templates/settings/general.twig
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,6 @@
errors: settings.getErrors('primarySiteUrl')
}) }}

<hr>
{{ forms.lightswitchField({
label: "Run Backup job in Background"|t('enupal-backup'),
instructions: 'Enable this setting for heavy backups',
id: 'runJobInBackground',
name: 'runJobInBackground',
on: settings.runJobInBackground,
toggle: 'settings-runJobInBackground',
onLabel: "On"|t('enupal-backup'),
offLabel: "Off"|t('enupal-backup')
}) }}

<hr>
{{ forms.lightswitchField({
label: "Use exec"|t('enupal-backup'),
Expand Down
6 changes: 4 additions & 2 deletions src/templates/settings/schedule.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{% set settings = craft.enupalbackup.getSettings() %}
{% set fullPageForm = true %}
{% set saveShortcutRedirect = 'enupal-backup/settings/schedule' %}
{% set craftPath = craft.enupalbackup.getCraftPath() %}

{% set saveButton %}
<div class="buttons">
Expand All @@ -31,7 +32,7 @@
{% namespace 'settings' %}
{{ forms.field({
label: "Webhook"|t('enupal-backup')|upper,
instructions: "Enupal Backup provides you a webhook to schedule your backups, here is an example how to do it with <a target='_blank' href='https://de.wikipedia.org/wiki/Cron'>Cron.</a> Adding one of the following lines to your crontab will execute your backup every morning at 3:10 AM."|t('enupal-backup'),
instructions: "Enupal Backup provides you a webhook to schedule your backups, here is an example how to do it with <a target='_blank' href='https://de.wikipedia.org/wiki/Cron'>Cron.</a> Adding one of the following lines to your crontab will execute your backup every morning at 3:11 AM."|t('enupal-backup'),
}, null) }}
<hr>

Expand Down Expand Up @@ -78,7 +79,8 @@
# * * * * *

# Enupal Backup Webhook
10 3 * * * wget {{webhookUrl}} -O /dev/null
10 3 * * * curl --request GET '{{webhookUrl}}'
11 3 * * * cd {{ craftPath }} && php craft queue/run

</pre>
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/variables/BackupVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,10 @@ public function processPendingBackups()
{
Backup::$app->backups->processPendingBackups();
}

public function getCraftPath()
{
return CRAFT_BASE_PATH;
}
}

0 comments on commit eb3cfa4

Please sign in to comment.