Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • The target database has the right schema, tables, etc, and is empty. See the create scripts in the scripts/ directory.
  • Both the source and destination database are called filesender

Postgres to MySQL

pgdump

add backticks to field values

...

Shell script that does:

  1. pg_dump
  2. Quote field names with backticks
  3. Remote any SET statements

...

  1. Remove any SELCT pg_catalog.setval statements

Code Block
themeMidnight
languagebash
pg_dump -U username -h hostname -a --inserts -t 'files' -t 'logs' filesender |
sed -r 's/^(INSERT\ INTO\ )(files|logs)(\ VALUES\ )/\1`\2`\3/g' |
sed -r '/SET\ ([a-z_]*)\ =\ (.*);/d' |
sed -r '/SELECT\ pg_catalog.setval(.*);/d' |
mysql -u username -h hostname -p filesender

...

Code Block
themeMidnight
languagebash
pg_dump -U username -h hostname -a --inserts -t 'files' -t 'logs' filesender |
grepsed --color=never "r '/^INSERT INTO" (file|log)s/!d' |
sed -r '/SET\ ([a-z_]*)\ =\ (.*);/d' |
sed -r '/SELECT\ pg_catalog.setval(.*);/d' |
sqlite3 filesender.sqlite

...