Drush extension to shrink database size by wiping older content.
The functionality is provided as a Drush command (shrinkdb), and also integrated as options to sql-sanitize.
At present it only works with Drush 8 and Drupal 8.
Table of Contents
Features
- Wipes content older than given days, 15 by default.
- Special handling for dependant entity types (comment, paragraph):
For better consistency, instead of deleting older ones, it deletes the orphaned ones,
after wiping parent entity types. - Wipes all entity tables (base fields, fields and revisions).
- Hookable so you can extend the base functionality. See
shrinkdb.api.php. - Leverages the great drush_entity.
Screenshots
$ drush help shrinkdb</p>
<p>Shrink the database size by wiping content older than given days.</p>
<p>Options:
--days=<15> Age (in days) of the contents to preserve. 15 by default.
$ drush shrinkdb
Do you really want to wipe content older than 15 days in the current database? (y/n): y
$ drush help sql-sanitize</p>
<p>Run sanitization operations on the current database. You can add more sanitization to this command by implementing hook<em>drush</em>sql<em>sync</em>sanitize().</p>
<p>Options:
--db-prefix Enable replacement of braces in sanitize queries.
--db-url=<mysql://root:pass@127.0.0.1/db> A Drupal 6 style database URL.
--sanitize-email=<user+%uid@localhost> The pattern for test email addresses in the sanitization operation, or "no" to keep email addresses unchanged. May contain replacement patterns %uid, %mail or %name.
--sanitize-password=<password> The password to assign to all accounts in the sanitization operation, or "no" to keep passwords unchanged.
--shrink-db Shrink the database size by wiping content older than given days.
--shrink-db-days=<15> Age (in days) of the contents to preserve. 15 by default.
$ drush @site sql-sanitize --shrink-db</p>
<p>The following operations will be done on the target database:
* Wipe content older than 15 days
* Reset passwords and email addresses in users<em>field</em>data table
* Truncate Drupal's sessions table
Install instructions
In a Composer based Drupal codebase
Package drupal/drush_shrinkdb is available at http://packages.drupal.org/8.
You can require it in your composer project as usual:
composer require drupal/drush_shrinkdb
System wide installation
You can perform a system-wide installation with drush dl (Drush 8) or downloading the tgz / clonning the repository.
mkdir -p /usr/share/drush/commands
cd /usr/share/drush/commands
# drush dl drush_shrinkdb
# git clone git clone --branch 8.x-1.x https://git.drupalcode.org/project/drush_shrinkdb.git
cd drush_shrinkdb
composer install
Usage
drush @site shrinkdb
drush @site shrinkdb --days=90</p>
<p>drush @site sql-sanitize --shrink-db
drush @site sql-sanitize --shrink-db --shrink-db-days=90
Author Information
Jonathan Araña Cruz - SB IT Media, S.L.
Supporting organizations:
sponsors the development
Project information
Seeking new maintainer
The current maintainers are looking for new people to take ownership.- Project categories: Developer tools
- Ecosystem: Drush
- Created by jonhattan on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
