Конвертафция путей в MySQL дампе для переноса на новый сервер
convert_paths.php
$
<?php
// старый путь
$old = '/var/www/looksochi/data/www/somesite.ru/';
// новый путь
$new = '/sites/rebirth/somesite.ru/';
// исходный дамп
$input = fopen('dump.sql','r');
// выходной файл
$output = fopen('dump_new.sql','w');
function rs($r){
global $old, $new;
return $r[1].( $r[2] + (strlen($new)-strlen($old)) ).$r[3];
}
while(($s = fgets($input)) !== false){
$s = preg_replace_callback('#(s\:)(\d+)(\:\x5C"'.preg_quote($old,'#').')#ms', 'rs', $s);
$s = str_replace($old, $new, $s);
fwrite($output, $s);
}
fclose($input);
fclose($output);
$
php -f convert_paths.php
6 комментариев
Заменит 'old/path' на 'new/path'
При настройке charset ставить utf8