定制 miguilim/laravel-singlestore-backup 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

miguilim/laravel-singlestore-backup

Composer 安装命令:

composer require miguilim/laravel-singlestore-backup

包简介

A package that makes it easy to make backups of your SingleStore database.

README 文档

README

Laravel SingleStore Backup is a package that makes it easy to make backups of your SingleStore database to your favorite storage. Behind the scenes, this package uses the BACKUP DATABASE command, a native command from SingleStore DB engine.

Contents

Installation

You can install the package via composer:

composer require miguilim/laravel-singlestore-backup

Supported Drivers

This package supports the following backup drivers:

  • Local - local
  • S3 / S3 compatible - s3
  • Google Cloud Storage - gcs
  • Azure Blobs - azure

Configuring

You must add the following lines to your .env file in order to configure your S3 credentials:

SINGLESTORE_BACKUP_DRIVER=

# Local / External storage
SINGLESTORE_BACKUP_PATH= 

# External storage (S3 / GCS / Azure)
SINGLESTORE_BACKUP_ENDPOINT=
SINGLESTORE_BACKUP_BUCKET=
SINGLESTORE_BACKUP_PUBLIC_KEY=
SINGLESTORE_BACKUP_SECRET_KEY=

# S3 storage (optionals)
SINGLESTORE_BACKUP_REGION=
SINGLESTORE_BACKUP_MULTIPART_CHUNK_SIZE=
SINGLESTORE_BACKUP_FORCE_PATH_STYLE=
SINGLESTORE_BACKUP_COMPATIBILITY_MODE=

Basic Usage

Below there is a simple example of how you use the backup command. By default, the command will do a full backup.

php artisan singlestore:backup

Setting Timeout Parameter

You can set the timeout parameter, a value specified in milliseconds, to determines the length of time to wait for the BACKUP DATABASE command to commit across the cluster. If not specified, the default_distributed_ddl_timeout global variable value is used.

php artisan singlestore:backup --timeout=30000

Setting With Date Parameter

If you want to add the date to the backup name, you can do that by using the --with-date parameter.

php artisan singlestore:backup --with-date

Setting With Time Parameter

If you want to add the time to the backup name, you can do that by using the --with-time parameter.

php artisan singlestore:backup --with-time

Important

The --with-date and --with-time parameters cannot be used in an incremental backup.

Init Backup

If you're making an incremental backup and want to create the INIT backup, you can do that by using the --init parameter.

php artisan singlestore:backup --init

Differential Backup

If you're making an incremental backup and want to do a DIFFERENTIAL backup, you can do that by using the --differential parameter.

php artisan singlestore:backup --differential

Prune Backups

You can prune backups by using the singlestore:prune-backups command. This command will prune the {$database}.backup directory by default.

php artisan singlestore:prune-backups

Important

All pruning command can only be executed with the s3 driver, and they follow the path specified in the SINGLESTORE_BACKUP_PATH environment variable.

Prune Incremental Backups

If you want to prune incremental backups, you can do that by using the --incremental parameter. This will prune the {$database}.incr_backup directory.

php artisan singlestore:prune-backups --incremental

Prune Backups Older Than Days

If you want to prune backups older than a certain number of days, you can do that by using the --older-than-days parameter. This will prune the {$database}_(.*?).backup (respecting the date) directory.

php artisan singlestore:prune-backups --older-than-days=30

Prune Backups Older Than Date

If you want to prune backups older than a certain date, you can do that by using the --older-than-date parameter. This will prune the {$database}_(.*?).backup (respecting the date) directory.

php artisan singlestore:prune-backups --older-than-date=2024-01-01

Important

Be careful when using the --older-than-date or --older-than-days parameters. They will prune all directories matched with the {$database}_(.*?).backup pattern + respecting the date specified. It may delete other unrelated directories if they match the pattern.

Advanced Usage

Sometimes the simple backup command with configs may not be flexible as you want. Instead, you can use the SinglestoreBackup class:

use Miguilim\LaravelSinglestoreBackup\SinglestoreBackup;

$backupInstance = new SinglestoreBackup(
    driver: 'local',
    database: 'mydatabase',
    path: '/my-backup/path'
);

$result = $backupInstance->executeQuery();

Available arguments:

  • driver
  • database
  • path
  • endpoint
  • timeout
  • publicKey
  • secretKey
  • bucket
  • init
  • differential
  • region
  • multipartChunkSizeMb
  • s3ForcePathStyle
  • compatibilityMode
  • withDate
  • withTime

Publishing Config File

You can publish the package configuration file to your project with the following command:

php artisan vendor:publish --tag=singlestore-backup-config

License

Laravel SingleStore Backup is open-sourced software licensed under the MIT license.

miguilim/laravel-singlestore-backup 适用场景与选型建议

miguilim/laravel-singlestore-backup 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.95k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2023 年 08 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 miguilim/laravel-singlestore-backup 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 miguilim/laravel-singlestore-backup 我们能提供哪些服务?
定制开发 / 二次开发

基于 miguilim/laravel-singlestore-backup 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.95k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-07