Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not enough user ratings | Total: 195 | All time: 8,533 This week: 82 |
Version | License | PHP version | Categories | |||
database-backup 1.0.0 | Shareware | 8 | Databases, Systems administration, PHP 8 |
Description | Author | |||||||||||||||||||||||
This package can take a database backup periodically. Innovation Award |
|
Takes database backup after certain interval
## Usage
use DatabaseBackup\Backup; use DatabaseBackup\Helpers\Console;
// Backup Class (NucleusBackup.php) class NucleusBackup extends AbstractBackup {
protected bool $sendMailOnError = false;
protected bool $sendMailOnSuccess = false;
public function interval(): int
{
return 2_000;
}
public function filePath(): string
{
return sprintf('%s/nucleus-%s.sql', dirname(__DIR__, 2), uniqid());
}
public function onSuccess(string $path, callable $done): void
{
$done();
Console::info('nucleus backup completed');
unlink($path);
}
public function connection(): DatabaseConnection
{
return new DatabaseConnection(
driver: DatabaseDriver::MYSQL,
host: 'localhost',
username: 'root',
password: '1234',
database: 'nucleus'
);
}
}
// Runner (run.php) use Swoole\Runtime; use DatabaseBackup\Backup; use DatabaseBackup\Helpers\Console;
require __DIR__ . '/vendor/autoload.php';
Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
Console::writeln("Backup service started");
// Run backups Backup::new()->start([NucleusBackup::class]);
### Mail Notification
use DatabaseBackup\Backup;
$receivers = [
new MailReceiver(
email: 'jane.doe@example.com',
name: 'Jane Doe'
),
];
$smtp = new SmtpCredential(
host: 'localhost',
port: 8025,Helpers
username: 'noreply@example.com',
password: 'Password',
auth: false
);
Backup::new()
->withSmtp($smtp)
->withMailReceivers($receivers)
->start([NucleusBackup::class]);
This library is MIT Licenced
Enjoy ?
Files (15) |
File | Role | Description | ||
---|---|---|---|---|
src (8 files, 2 directories) | ||||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
phpstan.neon | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files (15) | / | src |
File | Role | Description | ||
---|---|---|---|---|
Helpers (1 file) | ||||
Services (2 files) | ||||
AbstractBackup.php | Class | Class source | ||
Backup.php | Class | Class source | ||
Coroutine.php | Class | Class source | ||
DatabaseConnection.php | Class | Class source | ||
DatabaseDriver.php | Aux. | Auxiliary script | ||
MailReceiver.php | Class | Class source | ||
NoSmtp.php | Class | Class source | ||
SmtpCredential.php | Class | Class source |
Files (15) | / | src | / | Services |
File | Role | Description |
---|---|---|
BackupService.php | Class | Class source |
MailService.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.