微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在Spatie Laravel备份中仅保存5个最近的备份?

如何解决如何在Spatie Laravel备份中仅保存5个最近的备份?

我已经在我的应用程序中配置了Spatie / Laravel备份,并且为此做了固定的工作,每天自动进行备份。但是我可以只保存最近的5或10个系统备份吗? 如果创建了新备份,则应删除最旧的备份! 这是我备份配置文件的清理策略:

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

            /*
             * The number of days for which backups must be kept.
             */
            'keep_all_backups_for_days' => 7,/*
             * The number of days for which daily backups must be kept.
             */
            'keep_daily_backups_for_days' => 16,/*
             * The number of weeks for which one weekly backup must be kept.
             */
            'keep_weekly_backups_for_weeks' => 8,/*
             * The number of months for which one monthly backup must be kept.
             */
            'keep_monthly_backups_for_months' => 4,/*
             * The number of years for which one yearly backup must be kept.
             */
            'keep_yearly_backups_for_years' => 2,/*
             * After cleaning up the backups remove the oldest backup until
             * this amount of megabytes has been reached.
             */
            'delete_oldest_backups_when_using_more_megabytes_than' => 5000,],

这是创建备份的功能

 public function create()
    {
        try {
            // start the backup process
            \Illuminate\Support\Facades\Artisan::call('backup:run');
            $output = \Illuminate\Support\Facades\Artisan::output();
            // log the results
            Log::info("Backpack\backupmanager -- new backup started from admin interface \r\n" . $output);
            // return the results as a response to the ajax call
            return redirect('/backups')->with('message','Backup Created Successfully!')->with('alertType','alert-success');
        } catch (Exception $e) {
            return redirect('/backups')->with('message','Backup Failed,Try again')->with('alertType','alert-warning');
        }
    }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?