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

 
7 chiến lược bán hàng trực tuyến hiệu quả nhất

7 chiến lược bán hàng trực tuyến hiệu quả nhất

Không có một bí quyết nào về việc đẩy mạnh doanh số bán hàng qua Internet. Bạn thu hút sự chú ý của đông đảo mọi người và gia tăng các khách hàng tiềm năng. Khi đó, bạn gắn kết với họ và chuyển những mối quan tâm của họ thành các giao dịch mua sắm.

Drupal 8 và Backdrop CMS

So sánh 10 điểm khác biệt giữa Drupal 8 và Backdrop CMS

Many of you reading this will be familiar with Backdrop, but for those of you who haven't heard of the project,

MacOS X 10.8 Mountain Lion

Trên Apple Store - MacBook Air được bán giá từ 679 USD

Các mẫu laptop siêu mỏng của Apple thế hệ ra mắt năm 2010 được bán dưới dạng hàng tân trang lại (refurbished) có cấu hình khá với chip Core 2 Duo, RAM tối đa 4 GB và ổ cứng tối đa 128 GB.

Công ty diệt chuột T&C

 

Diet con trung