Jump to content

Data dumps/Import examples/catswiki bash script

From Meta, a Wikimedia project coordination wiki
#!/bin/bash

date > import-timing.txt
for table in \
      categorylinks  category  externallinks  imagelinks  interwiki  iwlinks \
      langlinks  pagelinks  page_props  page_restrictions  protected_titles \
      redirect templatelinks \
      page  revision  text ; \
  do
    echo "TRUNCATE TABLE $table ; " | mysql -u root -pnotverysecure enwiki
done

for f in  \
    catswiki/enwiki-20130304-categorylinks.sql.gz catswiki/enwiki-20130304-category.sql.gz \
    catswiki/enwiki-20130304-externallinks.sql.gz catswiki/enwiki-20130304-imagelinks.sql.gz \
    catswiki/enwiki-20130304-interwiki.sql.gz catswiki/enwiki-20130304-iwlinks.sql.gz \
    catswiki/enwiki-20130304-langlinks.sql.gz catswiki/enwiki-20130304-pagelinks.sql.gz \
    catswiki/enwiki-20130304-page_props.sql.gz catswiki/enwiki-20130304-page_restrictions.sql.gz \
    catswiki/enwiki-20130304-protected_titles.sql.gz catswiki/enwiki-20130304-redirect.sql.gz \
    catswiki/enwiki-20130304-templatelinks.sql.gz catswiki/filteredsql-page.sql-1.21.gz \
    catswiki/filteredsql-revision.sql-1.21.gz catswiki/filteredsql-text.sql-1.21.gz ; \
  do
    ( \
      echo "SET autocommit=0; SET unique_checks=0; SET foreign_key_checks=0;" ; \
      zcat $f ;  \
      echo "SET autocommit=1; SET unique_checks=1; SET foreign_key_checks=1;" \
    ) | mysql -u root -pnotverysecure enwiki
done
date >> import-timing.txt