Dump-cut » История » Версия 5
Андрей Волков, 2015-04-13 17:23
1 | 1 | Андрей Волков | h1. Dump-cut |
---|---|---|---|
2 | |||
3 | Перобразование дампа в схему: |
||
4 | |||
5 | <pre> |
||
6 | 2 | Андрей Волков | nice -n19 bzcat db.backup-2011-07-15.sql.bz2 \ |
7 | |nice -n19 awk ' |
||
8 | BEGIN{ |
||
9 | 5 | Андрей Волков | search_comment=1; |
10 | search_data=0; |
||
11 | write_out=1 |
||
12 | 2 | Андрей Волков | } |
13 | { |
||
14 | 5 | Андрей Волков | if ((search_comment==0)&&(search_data==1)&&($0 ~ /^COPY /)) { |
15 | write_out=0; |
||
16 | 2 | Андрей Волков | printf ("\n%s",$2) >"/dev/stderr" |
17 | } |
||
18 | 5 | Андрей Волков | if ((search_comment==1)&&($0 ~ /^-- Data for Name: /)) { |
19 | search_data=1; |
||
20 | search_comment=0; |
||
21 | 2 | Андрей Волков | }; |
22 | 5 | Андрей Волков | if (write_out==1) print $0; |
23 | if ((write_out==0)&&($0 ~ /^\\\.$/)) { |
||
24 | write_out=1; |
||
25 | search_data=0; |
||
26 | search_comment=1 |
||
27 | 2 | Андрей Волков | }; |
28 | if (NR%1000==0) printf "." > "/dev/stderr" |
||
29 | } |
||
30 | END{ |
||
31 | printf "\nDONE\n" > "/dev/stderr" |
||
32 | }' \ |
||
33 | |nice -n19 bzip2 -9 > db-cut.backup-2011-07-15-schema.sql.bz2 |
||
34 | 1 | Андрей Волков | </pre> |
35 | 3 | Андрей Волков | |
36 | 4 | Андрей Волков | h2. Выкусывание таблиц из дампа |
37 | 3 | Андрей Волков | |
38 | <pre> |
||
39 | pv -petraW blizko.backup-2014-01-30.sql.bz2 | nice -n19 bunzip2 | nice -n19 sed -e -n '/^COPY products (.*) FROM stdin;$/,/^\\.$/p;/^\\.$/q' | nice -n19 gzip -3 > products-2014-01-30_00-51.sql.gz |
||
40 | </pre> |