Pages

Move old Koha database to new installation

1. Backup of old Koha
Take the backup of your existing Koha database. Either you can make use a database kept in your pen drive otherwise you can apply following command to take the backup,

sudo mysqldump -uroot -p koha_library | xz > koha_library.sql.xz

Put MySQL root password, when it asks.

2. Install Koha

Follow the instructions in Koha wiki

3. Restoration of old Koha database to a new one
Remove the existing database in the new Koha installation

sudo mysql -uroot -p 

[Enter the Linux password and after that enter MySQL Root password]

drop database koha_library;
create database koha_library;
quit;

Copy your database backup from your pen drive to home folder.
Extract the backup file, the extension will be .sql
Then restore the old backup to the new Koha installation.

Database Restoration commands,

sudo mysql -uroot -p koha_library < koha_library.sql     
[Check name of your source Koha database] 
exit

koha_library - name of database in new installation
koha.sql - name of database in old installation
Enter the MySQL root password.

4. Upgrade Database Schema
Database schema of old Koha should upgrade to match with the new version. Apply following commands in a terminal one by one,

sudo service memcached restart

sudo koha-upgrade-schema library

5. Rebuild the Zebra Index.

Apply following command in a terminal,

sudo koha-rebuild-zebra -v -f library

23 comments:

  1. how to convert koha 2 mrc database file into koha 3

    ReplyDelete
    Replies
    1. It need lot of editing work. Make use MarcEdit software to edit the marc file before import into Koha 3

      Delete
  2. it's a very helpful article,..Thanks for the share..
    "back up website"

    ReplyDelete
  3. Koha new version database may content new field, do the old koha's database will working with new version?

    ReplyDelete
  4. Hi guyz i got stuck on this stage (mysql -uroot -p koha_library < koha_library.sql )

    ReplyDelete
  5. Will this make the new database records available in the KOHA web application when I search in the KOHA catalogue ?

    ReplyDelete
  6. Hi
    I am currently running on ubuntu desktop 12.04 but it is currently running in virtual box and the librarian is entering books.
    I am trying to rehearse how to migrate koha to another machine. So i created another virtual box, i installed on it ubuntu server 11.04.

    I successfully installed Koha on it, i then followed the instructions on this blog to move the koha database to the new machine.
    Every things seems okey, but when i try to check for the books in the new koha, i could not find any.
    i however found some errors while running the sudo koha-rebuild-zebra -v -f library command.

    1901..........error retrieving biblio 1925 at /usr/share/koha/bin/migration_tools/rebuild_zebra.pl line 706.
    ................................................................................2001........................................error retrieving biblio 2055 at /usr/share/koha/bin/migration_tools/rebuild_zebra.pl line 706.
    2101...............................error retrieving biblio 2146 at /usr/share/koha/bin/migration_tools/rebuild_zebra.pl line 706.
    ................................................

    ReplyDelete
  7. For some reason i cannot understand your question, but the reason as to why i posted the question was because, after going through the entire process, i tried searching for the books which i was trying to move to the new koha installation, but they were not there.

    But i figured what the problem was.
    Before i jump into it, just one correction, I was trying it on Ubuntu server 14.04 and not Ubuntu server 11.04 as earlier stated.

    The problem was while when installing the Perl modules at the cpan interface, it did some activity and then it says "Killed" and then breaks out of the interface, being a newbie, i thought that was it. So when i checked on the modules i realized there were not intalled,

    To solve the "Killed" error, i increased the RAM from 512 mb to 1GB,
    I also noticed after a long installation of Test::DBix::Class, it still indicated as not installed. So i downloaded it using wget, i installed manually.
    I tried installing the rest of the perl modules, i how ever failed to install the "HTTPD::Bench::ApacheBench" module. It threw an unknown error.

    I proceeded normally and it worked out, all the books are there.

    ReplyDelete
    Replies
    1. Koha can work well Without Test::DBix::Class

      Delete
  8. Yes Koha was working by itself, the issue was restoring the database from the old version of Koha, every thing went on well but when i tried to find the books, they weren't there.

    Unless you mean to say that the cause of the issue was not the absence of Test::DBIx::Class, then i don't understand why the books did not show up the first time.

    ReplyDelete
    Replies
    1. Follow step 4. Upgrade table structure.
      Rebuild zebra index

      Delete
  9. Thanks guys but i do get an error or a flaw about my old DB being too bulky.
    I also tried to edit the max upload size but all in vain. What am i doing wrong?
    I tired using Webmin for uploading Koha old DB but also it complains about the same upload size being way over board. Thats where am stuck thus far. Any monkey tricks to go about it will be great.

    ReplyDelete
  10. While restoring the backup after koha-upgrade-scha library command I got an error
    upgrading database schema for library DBD::mysql:: db do failed.Table 'koha-library system preferences doesn't exist for statement .Select * FROM system preferences WHERE 1=0"] at usr/share/koha/lib/koha/Database.pm line 93

    ReplyDelete
    Replies
    1. Could you open staff client successfully after executing koha-upgrade-scha library command?

      Delete
  11. Hie Guys,
    How do I solve this error,its comes when I try to delete a patron account in Koha:
    Software error:

    DBIx::Class::Storage::DBI::_dbh_execute(): Unknown column 'me.debarredcomment' in 'field list' at /usr/share/koha/lib/C4/Members.pm line 1802

    For help, please send mail to the webmaster ([no address given]), giving this error message and the time and date of the error.

    ReplyDelete
  12. after update I cannot login..
    May I know where to see error of the whole process

    ReplyDelete
  13. I wanto to migrate a Koha 3.20 data to a new and fresh Koha 16.x but only wants the biblio records with items and all user data with demographic info and circulation history. I want to use the "Koha offline circulation file format" (rnnung the persl script to generate the file from koha) for the user data and the koha tools for the bibliographic records. Any other idea? Any help? A Guide?

    ReplyDelete
    Replies
    1. Export marc file without item information.
      Generate patron list through report.
      Generate circulation details either through a report.

      Then install Koha.
      Then import marc file and patron details.
      Then import transaction details through .koc file (offline circulation).

      Delete
  14. Thanks...But can Koha be backed up with any software? Is it possible to use a software to backup koha in an external hard disk? and reload it on a new computer?

    ReplyDelete
    Replies
    1. Backup connect to a cloud storage like Google Drive or Dropbox.

      Delete
  15. is possible apply that solutions to migrate koha's database from 3.14 to 17.05 ?

    ReplyDelete
  16. This blog is very helpful.I did installation to migration with the help of this.My query is How can i put copies of the same book in one record...when i did all copies are of different record...Please help...and thank you for this blog

    ReplyDelete
    Replies
    1. Please see the Attach item feature in the following link,
      https://koha-community.org/manual/17.05/html/06_cataloging.html?highlight=attach%20item

      Delete