FileSender supports several different database back-ends, by virtue of PHP's PDO.
Currently there are 3 back-ends that are known to work: PostgreSQL, MySQL, and SQLite.
Assumptions:
- 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
Shell script that does:
- pg_dump
- Quote field names with backticks
- Remote any SET statements
- Remove any SELCT pg_catalog.setval statements
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
PostgreSQL to SQLite
pg_dump -U username -h hostname -a --inserts filesender | sed -r '/^INSERT INTO (file|log)s/!d' | sed -r '/SET\ ([a-z_]*)\ =\ (.*);/d' | sed -r '/SELECT\ pg_catalog.setval(.*);/d' | sqlite3 filesender.sqlite
SQLite to PostgreSQL
fixme
sqlite3 filesender.sqlite | grep -E --color=never "^INSERT\ INTO\ \"(logs|files)\" VALUES" | psql -U username -h hostname filesender
SQLite to MySQL
fixme
sqlite3 filesender.sqlite .dump | sed -r 's/^(INSERT\ INTO\ )"(logs|files)"(\ VALUES)/\1`\2`\3/g' | grep --color=never "^INSERT INTO \`" | mysql -u username -h hostname -p filesender
MySQL to PostgreSQL
asdf
MySQL to SQLite
asdfasd