Skip to content

Commit

Permalink
add backup database to dropbox
Browse files Browse the repository at this point in the history
  • Loading branch information
smajti1 committed Dec 11, 2023
1 parent 13df9ba commit 5c7dba3
Show file tree
Hide file tree
Showing 10 changed files with 1,008 additions and 60 deletions.
7 changes: 6 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@ PUSHER_APP_SECRET=

GOOGLE_MAPS_KEY=

DOCKER_WORK_DIR=/var/www
DOCKER_RESTART=unless-stopped

# dropbox backup db
DROPBOX_APP_KEY=
DROPBOX_APP_SECRET=
DROPBOX_ACCESS_TOKEN=
DROPBOX_MAIL_NOTIFICATION=
7 changes: 3 additions & 4 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace App\Console;

Expand All @@ -14,8 +14,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
$schedule->command('backup:run --only-db')->daily();
}

/**
Expand All @@ -25,7 +24,7 @@ protected function schedule(Schedule $schedule)
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
$this->load(__DIR__ . '/Commands');

require base_path('routes/console.php');
}
Expand Down
35 changes: 35 additions & 0 deletions app/Providers/DropboxServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php declare(strict_types=1);

namespace App\Providers;

use Illuminate\Filesystem\FilesystemAdapter;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Filesystem;
use Spatie\Dropbox\Client;
use Spatie\FlysystemDropbox\DropboxAdapter;

class DropboxServiceProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
//
}

/**
* Bootstrap services.
*/
public function boot(): void
{
Storage::extend('dropbox', static function ($app, $config) {
$client = new Client(env('DROPBOX_ACCESS_TOKEN'));
$dropboxAdapter = new DropboxAdapter($client);
$filesystem = new Filesystem($dropboxAdapter, ['case_sensitive' => false]);

return new FilesystemAdapter($filesystem, $dropboxAdapter);
});
}
}
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
"php": "^8.3",
"ext-intl": "*",
"ext-pdo": "*",
"ext-zip": "*",
"cviebrock/eloquent-sluggable": "^10.0",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^v10.35",
"laravel/tinker": "~2.1",
"laravel/ui": "^4.0",
"smajti1/laravel-wizard": "^1.5"
"smajti1/laravel-wizard": "^1.5",
"spatie/flysystem-dropbox": "^3.0",
"spatie/laravel-backup": "^8.4"
},
"require-dev": {
"barryvdh/laravel-debugbar": "~3.2",
Expand Down
Loading

0 comments on commit 5c7dba3

Please sign in to comment.