[Bug 15664] koha-restore: Allow database dump to be restored to another Koha instance
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15664 --- Comment #6 from Rudolf Byker <rudolfbyker@gmail.com> --- Another option is to use sed to replace the USE and CREATE DATABASE commands using regular expressions. This can be done using pipes, without creating a new dump. I wrote this bash function a while ago, which imports a gzipped Koha sql-dump. The first argument is the name of the database you want to create, and the second argument is the file name to import from. function import_db { DB="$1" F="$2" # Change the database names when importing. REPLACE1="s/^CREATE DATABASE.*/CREATE DATABASE ${DB};/" REPLACE2='s/USE `koha_rsc`;/USE `'"${DB}"'`;/' # Can't import if it exists, so drop it. drop_db "$DB" echo "Importing database $DB from $F …" zcat "${F}" | sed "${REPLACE1}; ${REPLACE2}" | mysql -u "$MYSQL_USER" -p"$MYSQL_PASS" } -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org