您好!欢迎来到雅安论坛
关注我们
扫码关注官方微信
手机版
手机扫描直接访问
欢迎: 附近的朋友。
111111

laravel备份组件安装

[复制链接]
未命名 发表于 2022-10-21 12:38:05 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
第一步:
  1. $ composer require laravel-admin-ext/backup -vvv
复制代码
添加provider
  1. // config/app.php

  2. 'providers' => [
  3.     // ...
  4.     Spatie\Backup\BackupServiceProvider::class,
  5. ];
复制代码

第二部
  1. php artisan admin:import backup
复制代码

第三部:在数据库配置文件中加上如下代码(config/database.php)参照修改
  1. 'mysql' => [
  2.     'driver'            => 'mysql',
  3.     'host'              => env('DB_HOST', 'localhost'),
  4.     'database'          => env('DB_DATABASE', 'forge'),
  5.     'username'          => env('DB_USERNAME', 'forge'),
  6.     'password'          => env('DB_PASSWORD', ''),
  7.     'charset'           => 'utf8',
  8.     'collation'         => 'utf8_unicode_ci',
  9.     'prefix'            => '',
  10.     'strict'            => false,
  11.     'engine'            => null,
  12.     'dump' => [

  13.         'dump_binary_path' => '/path/to/directory/', // only the path, without `mysqldump` or `pg_dump`
  14.         // 'dump_binary_path' => '/Applications/MAMP/Library/bin/', // works for MAMP on Mac OS
  15.         // 'dump_binary_path' => '/opt/homebrew/bin/', // works for Laravel Valet on Mac OS
  16.         'use_single_transaction',
  17.         'timeout' => 60 * 5, // 5 minute timeout
  18.         // 'exclude_tables' => ['table1', 'table2'],
  19.         // 'add_extra_option' => '--optionname=optionvalue',
  20.     ]
  21. ],
复制代码
主要是dump备份路径位置

第四部:发布配置文件
  1. php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"
复制代码
第五步:config/bacpup.php内容如下:
  1. return [

  2.     'backup' => [

  3.         /*
  4.          * The name of this application. You can use this name to monitor
  5.          * the backups.
  6.          */
  7.         'name' => env('APP_URL'),

  8.         'source' => [

  9.             'files' => [

  10.                 /*
  11.                  * The list of directories and files that will be included in the backup.
  12.                  */
  13.                 'include' => [
  14.                     base_path(),
  15.                 ],

  16.                 /*
  17.                  * These directories and files will be excluded from the backup.
  18.                  *
  19.                  * Directories used by the backup process will automatically be excluded.
  20.                  */
  21.                 'exclude' => [
  22.                     base_path('vendor'),
  23.                     base_path('node_modules'),
  24.                 ],

  25.                 /*
  26.                  * Determines if symlinks should be followed.
  27.                  */
  28.                 'followLinks' => false,
  29.             ],

  30.             /*
  31.              * The names of the connections to the databases that should be backed up
  32.              * Only MySQL and PostgreSQL databases are supported.
  33.              */
  34.             'databases' => [
  35.                 'mysql',
  36.             ],
  37.         ],

  38.         'destination' => [

  39.             /*
  40.              * The filename prefix used for the backup zip file.
  41.              */
  42.             'filename_prefix' => '',

  43.             /*
  44.              * The disk names on which the backups will be stored.
  45.              */
  46.             'disks' => [
  47.                 'local',
  48.             ],
  49.         ],
  50.     ],

  51.     /*
  52.      * You can get notified when specific events occur. Out of the box you can use 'mail' and 'slack'.
  53.      * For Slack you need to install guzzlehttp/guzzle.
  54.      *
  55.      * You can also use your own notification classes, just make sure the class is named after one of
  56.      * the `Spatie\Backup\Events` classes.
  57.      */
  58.     'notifications' => [

  59.         'notifications' => [
  60.             \Spatie\Backup\Notifications\Notifications\BackupHasFailed::class         => ['mail'],
  61.             \Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFound::class => ['mail'],
  62.             \Spatie\Backup\Notifications\Notifications\CleanupHasFailed::class        => ['mail'],
  63.             \Spatie\Backup\Notifications\Notifications\BackupWasSuccessful::class     => ['mail'],
  64.             \Spatie\Backup\Notifications\Notifications\HealthyBackupWasFound::class   => ['mail'],
  65.             \Spatie\Backup\Notifications\Notifications\CleanupWasSuccessful::class    => ['mail'],
  66.         ],

  67.         /*
  68.          * Here you can specify the notifiable to which the notifications should be sent. The default
  69.          * notifiable will use the variables specified in this config file.
  70.          */
  71.         'notifiable' => \Spatie\Backup\Notifications\Notifiable::class,

  72.         'mail' => [
  73.             'to' => 'your@email.com',
  74.         ],

  75.         'slack' => [
  76.             'webhook_url' => '',
  77.         ],
  78.     ],

  79.     /*
  80.      * Here you can specify which backups should be monitored.
  81.      * If a backup does not meet the specified requirements the
  82.      * UnHealthyBackupWasFound event will be fired.
  83.      */
  84.     'monitorBackups' => [
  85.         [
  86.             'name' => env('APP_URL'),
  87.             'disks' => ['local'],
  88.             'newestBackupsShouldNotBeOlderThanDays' => 1,
  89.             'storageUsedMayNotBeHigherThanMegabytes' => 5000,
  90.         ],

  91.         /*
  92.         [
  93.             'name' => 'name of the second app',
  94.             'disks' => ['local', 's3'],
  95.             'newestBackupsShouldNotBeOlderThanDays' => 1,
  96.             'storageUsedMayNotBeHigherThanMegabytes' => 5000,
  97.         ],
  98.         */
  99.     ],

  100.     'cleanup' => [
  101.         /*
  102.          * The strategy that will be used to cleanup old backups. The default strategy
  103.          * will keep all backups for a certain amount of days. After that period only
  104.          * a daily backup will be kept. After that period only weekly backups will
  105.          * be kept and so on.
  106.          *
  107.          * No matter how you configure it the default strategy will never
  108.          * delete the newest backup.
  109.          */
  110.         'strategy' => \Spatie\Backup\Tasks\Cleanup\Strategies\DefaultStrategy::class,

  111.         'defaultStrategy' => [

  112.             /*
  113.              * The number of days for which backups must be kept.
  114.              */
  115.             'keepAllBackupsForDays' => 7,

  116.             /*
  117.              * The number of days for which daily backups must be kept.
  118.              */
  119.             'keepDailyBackupsForDays' => 16,

  120.             /*
  121.              * The number of weeks for which one weekly backup must be kept.
  122.              */
  123.             'keepWeeklyBackupsForWeeks' => 8,

  124.             /*
  125.              * The number of months for which one monthly backup must be kept.
  126.              */
  127.             'keepMonthlyBackupsForMonths' => 4,

  128.             /*
  129.              * The number of years for which one yearly backup must be kept.
  130.              */
  131.             'keepYearlyBackupsForYears' => 2,

  132.             /*
  133.              * After cleaning up the backups remove the oldest backup until
  134.              * this amount of megabytes has been reached.
  135.              */
  136.             'deleteOldestBackupsWhenUsingMoreMegabytesThan' => 5000,
  137.         ],
  138.     ],
  139. ];
复制代码

备份不能下载和删除,需要修改D:\WWW\syfw\vendor\laravel-admin-ext\backup\resources\views 里面的视图文件
111.jpg
详情可以看:https://www.yaanbbs.net/study/yaan30017/此文




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关注3

粉丝13

帖子2251

发布主题
阅读排行 更多
广告位
欢迎使用无需登录在线留言
姓名 

手机 

内容
关注我们
  • 关注官方微信

  • 论坛QQ群

Sitemap小黑屋Archiver雅安论坛( 已经安全运行 ) |网站地图

在线客服

会员收集的资源(插件源码等),仅方便学习,您需要自行承担版权风险,未获得原作者授权的情况下,请勿将文章公开发布或用于商业用途。

声明:本站内容来自于论坛作者本人的观点,不代表本网站的观点和看法,与本网站立场无关,相关责任作者自负。如有侵权,请联系我们及时删除

高能预警:本站为个人网站,非团队运作,常年务农,山上信号不好,在线少,如有不妥之处,望大佬们多多包涵,万分感激!

雅安论坛互联网违法和不良信息举报平台 您也可以通过留言进行相关问题提交,留言提交无需注册,我们将严格保证用户隐私。   © 2009-2021