Skip to content

Commit

Permalink
- Register health check through _config.php as YML was not registering
Browse files Browse the repository at this point in the history
- Change date formate to SS3
  • Loading branch information
Danae Miller-Clendon committed Jun 19, 2019
1 parent d4432df commit 0af0256
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
5 changes: 5 additions & 0 deletions _config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

use LittleGiant\SpinDB\Health\BackupCheck;

EnvironmentCheckSuite::register('check', BackupCheck::class, "Is the database backup saving to S3 daily?");
4 changes: 0 additions & 4 deletions _config/environmentcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,3 @@ EnvironmentCheckSuite:
registered_suites:
health:
- spindb
registered_checks:
spindb:
definition: 'LittleGiant\SpinDB\Health\BackupCheck'
title: 'Is the database backup saving to S3 daily?'
8 changes: 1 addition & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "littlegiant/silverstripe-spindb",
"type": "silverstripe-vendormodule",
"license": "BSD-3-Clause",
"description": "Backup DB periodically and backup to AWS S3 storage with rotation",
"require": {
Expand All @@ -18,12 +17,7 @@
],
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"LittleGiant\\SpinDB\\": "src/"
"dev-ss3": "dev-ss3.x-compat"
}
},
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions src/Configuration/RotateConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ protected static function getFixedArgs(): array
public static function getCurrentArgs(): array
{
return [
'date' => SS_Datetime::now()->Format('y-MM-dd'),
'time' => SS_Datetime::now()->Format('HH.mm.ss'),
'date' => SS_Datetime::now()->Format('Y-m-d'),
'time' => SS_Datetime::now()->Format('H.i.s'),
];
}

Expand Down Expand Up @@ -110,6 +110,7 @@ public static function parse($path): ?array
return null;
}


// Return array of matched parts
$result = [];
foreach ($patterns as $name => $value) {
Expand Down
6 changes: 5 additions & 1 deletion src/Storage/RotateStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

use Aws\Result;
use Aws\S3\S3Client;
use Debug;
use Exception;
use Injector;
use LittleGiant\SpinDB\Configuration\RotateConfig;
use Object;

Expand Down Expand Up @@ -66,7 +68,9 @@ public function getFiles()
]);
$files = [];
$objects = $objects->get('Contents');
if ($objects) {

if (!empty($objects)) {

foreach ($objects as $object) {
$parts = RotateConfig::parse($object['Key']);
if ($parts) {
Expand Down
1 change: 1 addition & 0 deletions src/Storage/S3ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Aws\Credentials\Credentials;
use Aws\S3\S3Client;
use LittleGiant\SpinDB\Configuration\RotateConfig;
use SilverStripe\Framework\Injector\Factory;

class S3ClientFactory implements Factory
{
Expand Down

0 comments on commit 0af0256

Please sign in to comment.