Loại bỏ 1 số tables bằng Drush sql-dump and sql-sync

Loại bỏ 1 số tables bằng Drush sql-dump and sql-sync

At KnackForge we use Drush more often as a part of Drupal development projects. As Drupal developers, we frequently feel the need for getting the most recent database dump from live site. When I did this recently, it was relatively a big site, thought it would be nice to skip a few tables that are not essential. At least to avoid unnecessary time spent on I/O operations. This is one of the few things that I have least tried with Drush.

Quick Google Search led me to Drush project issue in drupal.org, mostly outdated posts. Had to connect the dots found here and there to get eventually what I needed, hence writing this blog post.

To skip specific tables when using drush sql-dump and sql-sync, in drushrc.php need to have the below code in place,

<?php
$options['structure-tables'] = array(
  'common' => array(
    'cache',
    'cache_block',
    'cache_filter',
    'cache_form',
    'cache_menu',
    'cache_page',
    'cache_update',
    'history',
    'watchdog',
    'simplenews_subscription',
    'simplenews_subscriber',
    'customtable_1',
    'customtable_2'
  ),
);
$options['structure-tables-key'] = 'common';
?>

Once done, for all sql-dump and sql-sync commands you would issue, the above tables will be skipped.

Note: 

  1. Beware if any of the above table is not found in your Drupal database the command will fail to complete successfully
  2. To have skip list per site, you can place drushrc.php in sites/default/ folder.

Hope this will help.

Bạn thấy bài viết này như thế nào?: 
Average: 10 (1 vote)
Ảnh của Khanh Hoang

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Động cơ nào khiến Facebook "biếu không" người dùng những công nghệ tuyệt đỉnh

Facebook biếu không người dùng những công nghệ tuyệt đỉnh

Liên tiếp hàng loạt những công nghệ đình đám của Facebook ra mắt trong thời gian gần đây đều được hãng miễn phí cho người dùng

The Power of the Web

Sức mạnh của Website trong marketing online

Clayton Christensen's book, "The Innovator's Dilemma," rocked conventional business thinking when it came out in 1997. Christensen, a professor at Harvard Business School, showed that new technologies often failed because the companies offered new technologies to the existing customer base.

Hướng dẫn upgrading lên Drupal 8 - client bắt mắt

Hướng dẫn upgrading lên Drupal 8 - client bắt mắt

Having helped create the original Drupal 6 site for NAMA in 2008, it’s been a rewarding experience re-architecting it in Drupal 8 (beta).

Wordpress Freelancer

 

Wordpress Freelancer