backup.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <?php
  2. return [
  3. 'backup' => [
  4. /*
  5. * 此应用程序的名称。 您可以使用此名称进行监控
  6. * The name of this application. You can use this name to monitor
  7. * the backups.
  8. */
  9. 'name' => config('app.name'),
  10. 'source' => [
  11. 'files' => [
  12. /*
  13. * 将包含在备份中的目录和文件列表。
  14. */
  15. 'include' => [
  16. base_path(),
  17. ],
  18. /*
  19. * 这些目录和文件将从备份中排除。
  20. * These directories and files will be excluded from the backup.
  21. * 备份过程使用的目录将自动排除。
  22. * Directories used by the backup process will automatically be excluded.
  23. */
  24. 'exclude' => [
  25. base_path('vendor'),
  26. base_path('node_modules'),
  27. ],
  28. /*
  29. * 确定是否应遵循符号链接。
  30. * Determines if symlinks should be followed.
  31. */
  32. 'followLinks' => false,
  33. ],
  34. /*
  35. * 应备份的数据库的连接名称
  36. * 支持MySQL,PostgreSQL,SQLite 和 Mongo 数据库。
  37. *
  38. * 可以为每个连接定制数据库转储的内容
  39. * by adding a 'dump' key to the connection settings in config/database.php.
  40. * E.g.
  41. * 'mysql' => [
  42. * ...
  43. * 'dump' => [
  44. * 'excludeTables' => [
  45. * 'table_to_exclude_from_backup',
  46. * 'another_table_to_exclude'
  47. * ]
  48. * ]
  49. * ],
  50. *
  51. * 有关可用自定义选项的完整列表,请参阅 https://github.com/spatie/db-dumper
  52. */
  53. 'databases' => [
  54. 'mysql',
  55. ],
  56. ],
  57. /*
  58. * 可以压缩数据库转储以减少磁盘空间使用量。
  59. *
  60. * 开箱即用的 Laravel-backup
  61. * Spatie\DbDumper\Compressors\GzipCompressor::class.
  62. *
  63. * 您还可以创建自定义压缩器。 更多信息在这里:
  64. * https://github.com/spatie/db-dumper#using-compression
  65. *
  66. * 如果您根本不需要任何压缩器,请将其设置为 null
  67. */
  68. 'database_dump_compressor' => null,
  69. 'destination' => [
  70. /*
  71. * 用于备份zip文件的文件名前缀。
  72. */
  73. 'filename_prefix' => '',
  74. /*
  75. * 将存储备份的磁盘名称。
  76. */
  77. 'disks' => [
  78. 'local',
  79. ],
  80. ],
  81. /*
  82. * 将存储临时文件的目录。
  83. */
  84. 'temporary_directory' => storage_path('app/backup-temp'),
  85. ],
  86. /*
  87. * 您可以在特定事件发生时收到通知。 开箱即用你可以使用 'mail' 和 'slack'
  88. * 对于 Slack,你需要安装 guzzlehttp/guzzle。
  89. *
  90. * 您也可以使用自己的通知类,只需确保该类以“Spatie\Backup\Events”命名。
  91. * You can also use your own notification classes, just make sure the class is named after one of
  92. * the `Spatie\Backup\Events` classes.
  93. */
  94. 'notifications' => [
  95. 'notifications' => [
  96. \Spatie\Backup\Notifications\Notifications\BackupHasFailed::class => ['mail'],
  97. \Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFound::class => ['mail'],
  98. \Spatie\Backup\Notifications\Notifications\CleanupHasFailed::class => ['mail'],
  99. \Spatie\Backup\Notifications\Notifications\BackupWasSuccessful::class => ['mail'],
  100. \Spatie\Backup\Notifications\Notifications\HealthyBackupWasFound::class => ['mail'],
  101. \Spatie\Backup\Notifications\Notifications\CleanupWasSuccessful::class => ['mail'],
  102. ],
  103. /*
  104. * 您可以在此处指定通知应发送到的通知。 默认通知将使用此配置文件中指定的变量。
  105. */
  106. 'notifiable' => \Spatie\Backup\Notifications\Notifiable::class,
  107. 'mail' => [
  108. // 通知邮箱
  109. 'to' => '869904300@qq.com',
  110. ],
  111. 'slack' => [
  112. 'webhook_url' => '',
  113. /*
  114. * 如果将其设置为null,则将使用 webhook 的默认通道。
  115. */
  116. 'channel' => null,
  117. 'username' => null,
  118. 'icon' => null,
  119. ],
  120. ],
  121. /*
  122. * 您可以在此处指定应监视哪些备份。
  123. * 如果备份不符合指定的要求,将触发 UnHealthyBackupWasFound 事件。
  124. */
  125. 'monitorBackups' => [
  126. [
  127. 'name' => config('app.name'),
  128. 'disks' => ['local'],
  129. 'newestBackupsShouldNotBeOlderThanDays' => 1,
  130. 'storageUsedMayNotBeHigherThanMegabytes' => 5000,
  131. ],
  132. /*
  133. [
  134. 'name' => 'name of the second app',
  135. 'disks' => ['local', 's3'],
  136. 'newestBackupsShouldNotBeOlderThanDays' => 1,
  137. 'storageUsedMayNotBeHigherThanMegabytes' => 5000,
  138. ],
  139. */
  140. ],
  141. 'cleanup' => [
  142. /*
  143. * 将用于清除旧备份的策略。 默认策略会将所有备份保留一定天数。
  144. * 在此期间之后,仅保留每日备份。 在此期间之后,将仅保留每周备份,依此类推。
  145. *
  146. * 无论您如何配置它,默认策略都不会删除最新的备份。
  147. */
  148. 'strategy' => \Spatie\Backup\Tasks\Cleanup\Strategies\DefaultStrategy::class,
  149. 'defaultStrategy' => [
  150. /*
  151. * 必须保留备份的天数。
  152. */
  153. 'keepAllBackupsForDays' => 7,
  154. /*
  155. * 必须保留每日备份的天数。
  156. */
  157. 'keepDailyBackupsForDays' => 16,
  158. /*
  159. * 必须保留一周备份的周数。
  160. */
  161. 'keepWeeklyBackupsForWeeks' => 8,
  162. /*
  163. * 必须保留一个月备份的月数。
  164. */
  165. 'keepMonthlyBackupsForMonths' => 4,
  166. /*
  167. * 必须保留一年备份的年数。
  168. */
  169. 'keepYearlyBackupsForYears' => 2,
  170. /*
  171. * 清理备份后,删除最旧的备份,直到达到此兆字节数。
  172. */
  173. 'deleteOldestBackupsWhenUsingMoreMegabytesThan' => 5000,
  174. ],
  175. ],
  176. ];