Skip to content

Commit

Permalink
added timestamp to database dump file
Browse files Browse the repository at this point in the history
  • Loading branch information
boryn committed Oct 2, 2023
1 parent 31eba44 commit ffb41ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
*/
'database_dump_compressor' => null,

/*
* If specified, the database dumped file name will contain a timestamp (e.g.: 'Y-m-d-H-i-s').
*/
'database_dump_file_timestamp_format' => null,

/*
* The file extension used for the database dump files.
*
Expand Down
7 changes: 6 additions & 1 deletion src/Tasks/Backup/BackupJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,12 @@ protected function dumpDatabases(): array
$dbName = $key . '-database';
}

$fileName = "{$dbType}-{$dbName}.{$this->getExtension($dbDumper)}";
$timeStamp = '';
if ($timeStampFormat = config('backup.backup.database_dump_file_timestamp_format')) {
$timeStamp = '-' . Carbon::now()->format($timeStampFormat);
}

$fileName = "{$dbType}-{$dbName}{$timeStamp}.{$this->getExtension($dbDumper)}";

if (config('backup.backup.gzip_database_dump')) {
$dbDumper->useCompressor(new GzipCompressor());
Expand Down

0 comments on commit ffb41ed

Please sign in to comment.