albert-m
1/30/2016 - 11:33 PM

Синхронизация БД и файлов с сервера с помощью Drush

Синхронизация БД и файлов с сервера с помощью Drush

?php
 
// Tables to exclude from sql-sync
$options['skip-tables']['common'] = array('cache', 'cache_filter', 'cache_menu', 'cache_page', 'history', 'sessions', 'watchdog');
$custom_cache = array ('cache_admin_menu','cache_block','cache_bootstrap','cache_features','cache_field','cache_form','cache_image','cache_l10n_update','cache_libraries','cache_path','cache_token','cache_update','cache_views','cache_views_data');
$options['skip-tables']['common'] = array_merge($options['skip-tables']['common'], $custom_cache);
$command_specific['sql-sync'] = array('skip-tables-key' => 'common');

// Short aliases
$options['shell-aliases']['sitename-sync'] = '-y sql-sync --no-cache @sitename.remote @sitename.local';
$options['shell-aliases']['sitename-rsync'] = '-y rsync @sitename.remote:%files/ @sitename.local:%files --omit-dir-times --no-p';
<?php

$local_sites = '/home/[username]/localserver/'; // путь к локальной директории с сайтом
 
$aliases['sitename.local'] = array(
  'root' => $local_sites . 'sitename.loc',
  'path-aliases' => array(
    '%dump-dir' => $local_sites . 'drush.dbdumps',
    '%files' => $local_sites . 'sitename.loc/sites/default/files'
  )
);
 
$remote_sites = '/var/www/username/data/www/';
 
$aliases['sitename.remote'] = array (
  'root' => $remote_sites . 'sitename.ru',
  'remote-host' => '46.254.21.41',
  'remote-user' => 'islamrostov',
  'ssh-options' => "-p 22",
  'path-aliases' => array(
    '%dump-dir' => $remote_sites . 'drush.dbdumps',
    '%files' => $remote_sites . 'sitename.ru/sites/default/files'
  )
);