定制 grossberger-georg/typo3-snapshot 二次开发

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

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

grossberger-georg/typo3-snapshot

Composer 安装命令:

composer require grossberger-georg/typo3-snapshot

包简介

Create and restore database and fileadmin snapshots

README 文档

README

This is a TYPO3 extension for creating snapshots of the current installation on the CLI. It can create and restore them, make stubs for bigger file assets and anonymize DB data.

IMPORTANT: Currently this works with MySQL or compatibles only!

Installation

Use composer to add it composer require grossberger-georg/typo3-snapshot or load from TER and install it in the Extension Manager.

The programs tar and gzip must be available in $PATH / %PATH%.

Usage

The extension will add two new commands: snapshot:create and snapshot:restore. They can be invoked using the TYPO3 CLI script: ./vendor/bin/typo3 snapshot:create|restore. If the bin-dir setting is changed in the composer.json manifest, the commands listed here must be run accordingly.

Creating a snapshot

Running snapshot:create will create a snapshot inside the folder snapshot/, which is inside ROOT_PATH/var or DOCUMENT_ROOT/typo3temp/var, depending on the setup. A snapshot has a name, which is determined by the name of the folder its data is in.

The command takes an optional argument: the name of the snapshot to create. If no name is given, the current timestamp will be used and printed to stdout:

# Will create a snapshot in var/snapshot/dev/
vendor/bin/typo3 snapshot:create dev

# Will create a snapshot in var/snapshot/YYYYMMDDHHMMSS/
vendor/bin/typo3 snapshot:create

There are three additional switches:

Full Short Description
--files -f Add data of local storage drivers to the snapshot. By default, this is the fileadmin
--small -s Ensure a small snapshot by creating stubs and only saving referenced files
--anonymize -a Anonymize data in user tables. Defaults to sys_log, be_users, fe_users and tt_address

The --files switch

For each FAL storage using the Local Driver, a tar archive is created, containing all files inside it. In a typical installation, this is the content of the folder fileadmin/. Only the directory _processed_ is excluded.

It will create a file named [STORAGE_UID]--[STORAGE_NAME].tar.gz for each storage using the Local driver. For the fileadmin, a snapshot will contain its content in the archive file 1--fileadmin.tar.gz.

The --small switch

This is an addition to --files. Adding the switch --small has no effect without --files.

It reduces the size of a snapshot via two simple measures:

1. Creating stubs:

This will reduce the size of files which are larger than 100KB.

In case of images in a web format (gif, png, jpg and webp), as well as PDF files, a placeholder is generated, containing only the file name as text. Images will be the same dimensions as their originals. PDFs will have only one page.

Other filetypes, like binary downloads, will have their content replaced with the MD5 checksum of the original content. Their size will be reduced to a fixed 16 bytes. This means that files like ZIPs or executables will not work anymore!

2. Only adding referenced files

The table sys_file_reference is checked if a file in a storage is actually used on the page. If it is not, it is not added to the snapshot.

The --anonymize switch

This will anonymize possibly sensitive data in the exported records by pseudonymization and removal of certain pieces of information.

Currently, it works out of the box with sys_log, fe_user, be_users and tt_address. Only fields with not-empty values will be processed, empty fields are are left empty.

In case of login information (fe_users and be_users), the fields containing the username and the password are not changed. This is because this information is functional and cannot be changed without possible side effects. Also internal fields, like the UID, will not be changed.

Restoring a snapshot

This will restore a snapshot inside the folder var/snapshot by importing the database and, if enabled via the switch, unpacking the files into the root of their storages:

# Restore latest snapshot, including files
vendor/bin/typo3 snapshot:restore --files

# Restore snapshot "dev" without files, database only
vendor/bin/typo3 snapshot:restore dev

In case the name argument is not set, the snapshot is determined by using the first entry of an alphabetically sorted list of available snapshots. By default, snapshots are named using a timestamp, so the latest will be used.

Without the switch --files, only the database is restored.

Credits

The anonymizer uses the following static data sets for its operations:

License

Apache 2.0

grossberger-georg/typo3-snapshot 适用场景与选型建议

grossberger-georg/typo3-snapshot 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.67k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 06 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 grossberger-georg/typo3-snapshot 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.67k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2019-06-11