Difference between revisions of "Moving a repository"

From EPrints Documentation
Jump to: navigation, search
Line 1: Line 1:
 
[[Category:Management]]
 
[[Category:Management]]
  
=Complete Transfer=
+
==Migrate the MySQL database==
  
 +
You will require your database username, password and name, which can be found in:
  
 +
archives/[archiveid/cfg/cfg.d/database.pl
  
'''Moving an archive from one machine to another is a three-step process:'''
+
Dump the MySQL database for the repository:
  
# Transfer Mysql Database
+
$ mysqldump --user myrepo --password=XYXY myrepo | gzip > myrepo.sql.gz
# Transfer Eprints Configuration Files
 
# Reconfigure The Archive On the New Machine
 
  
'''Note: All of these steps are performed from the NEW machine.'''
+
Transfer the MySQL dump file to your new server e.g.:
  
--------
+
$ scp myrepo.sql.gz user@mynewserver:/tmp
  
!!Transfer Mysql Database
+
Create the MySQL database on the new server and give it the appropriate permissions:
  
Back up the Mysql database on the old machine.
+
$ mysql -u root -p
 +
{ root password }
 +
mysql> create database myrepo;
 +
mysql> grant all privileges on myrepo.* to myrepo@localhost identified by 'XYXY';
  
  shell> ssh 172.20.1.13    # you will be asked for the password
+
Load the database:
  shell> cd /root          #run the following command from root directory
 
  shell> mysqldump -p --quick test1 | gzip > test1.old.gz
 
  shell> exit              #leave the old server
 
  
Move the file to the new server and install it (do this as root).
+
$ gunzip -c /tmp/myrepo.sql.gz | mysql --user myrepo --password=XYXY myrepo
  
Note: The eprints indexer should not be running
+
==Migrate EPrints==
  
  shell> sftp 172.20.1.13  #remote login to FTP
+
Install the version of EPrints that you want to migrate to (e.g. you may want to upgrade).
  sftp > get /root/test1.old.gz /root
 
  sftp > quit
 
  shell> bin/indexer stop # just in case it is running
 
  shell> mysqladmin -p create test1
 
  shell> gunzip < /root/test1.old.gz | mysql -p test1
 
  shell> mysql -p
 
  mysql> show databases;    #test1 should be in the list
 
  mysql> quit
 
  shell> bin/indexer start
 
 
 
  
-------
+
==Migrate the Repository==
  
!!Transfer Eprints Configuration Files
+
Use tar and ssh to transfer your repository to the new server:
  
Tar up files on old server (logged on as root).
+
$ tar -czf - -C /opt/eprints3/archives myrepo/ | ssh user@mynewserver "tar -xzf - -C /opt/eprints3/archives"
  
  shell> ssh 172.20.1.13    # you will be asked for the password
+
Fix permissions and ownership:
  shell> cd /opt/eprints2/archives
 
  shell> tar cvf test1.tar /opt/eprints2/archives/test1
 
  shell> exit
 
  
Be sure you are logged onto the new server as root
+
$ chown -R eprints:eprints /opt/eprints3/
 +
$ chmod -R 02775 /opt/eprints3/archives/
  
  shell> sftp 172.20.1.13
+
===Migrate the Apache Configuration===
  sftp > get /opt/eprints2/archives/test1.tar /opt/eprints2/archives
 
  sftp > get /opt/eprints2/archives/test1.xml /opt/eprints2/archives
 
  sftp > quit
 
  shell> cd /
 
  shell> ls -l /opt/eprints2/archives    #check the ownership of files
 
  
If the files test1.tar and test1.xml are not owned by eprints, do the following:
+
If you have customised your Apache configuration you will need to transfer it:
  
  shell> chown eprints:eprints /opt/eprints2/archives/test1.xml
+
$ scp /opt/eprints3/cfg/apache/myrepo.conf user@mynewserver:/opt/eprints3/cfg/apache/myrepo.conf
  shell> chown eprints:eprints /opt/eprints2/archives/test1.xml
+
$ scp /opt/eprints3/cfg/apache_ssl/myrepo.conf user@mynewserver:/opt/eprints3/cfg/apache_ssl/myrepo.conf
  
Log on or su to the eprints user and untar the file (be sure you are in the root (/) directory!):
+
==Upgrading the Repository==
  
  shell> tar xvf /opt/eprints2/archives/test1.tar
+
'''Skip if you installed the same EPrints version'''
  
---------
+
$ ./bin/epadmin upgrade myrepo
  
 +
==Finishing==
  
!!Reconfigure The Archive On the New Machine
+
Make sure your repository is OK:
  
Move to the eprints2 directory.
+
$ ./bin/epadmin test
  
  shell> cd /opt/eprints2. #must be here to run following command
+
For example you may need to install extra dependencies.
  shell> bin/configure_archive test1
 
  
'''Note1:''' As you go through configure_archive, be very sure that if you change any of the settings from the default you know what you are doing and why!
+
Generate any missing Apache configuration:
  
'''Note2:''' If you are going to use the same URL on the new machine as you did on the old one, do not forget to update your local DNS server to point the URL to the new server.
+
$ ./bin/generate_apacheconf
  
'''Note3:''' You will be asked if you want to create the database or archive files. You do not want to do that as they are already there.
+
Restart Apache.
 
 
  shell> bin/generate_static test1
 
 
 
If you get an access denied error for the Mysql database, it is probably because the user has not been identified in Mysql. Add a new user (in this case, ''eprints'' is the new user) as follows:
 
 
 
  shell> mysql -p  #you will be prompted for the password
 
  mysql> grant all on test1.* to eprints@localhost;
 
  mysql> set password for eprints@localhost = password('eprints4ever');
 
  mysql> quit
 
 
 
Once generate_static completes without errors, continue:
 
 
 
  shell> bin/generate_abstracts test1
 
  shell> bin/generate_views test1
 
  shell> bin/generate_apacheconf
 
 
 
Do not forget to stop and start the apache server so the above changes can be applied.
 
 
 
--------
 
 
 
'''Contributor'''
 
 
 
->Archie Trammell
 
->SIL International
 
->7500 W Camp Wisdom Road
 
->Dallas, TX  USA
 
->archie_trammell@sil.org
 

Revision as of 15:12, 18 May 2012


Migrate the MySQL database

You will require your database username, password and name, which can be found in:

archives/[archiveid/cfg/cfg.d/database.pl

Dump the MySQL database for the repository:

$ mysqldump --user myrepo --password=XYXY myrepo | gzip > myrepo.sql.gz

Transfer the MySQL dump file to your new server e.g.:

$ scp myrepo.sql.gz user@mynewserver:/tmp

Create the MySQL database on the new server and give it the appropriate permissions:

$ mysql -u root -p
{ root password }
mysql> create database myrepo;
mysql> grant all privileges on myrepo.* to myrepo@localhost identified by 'XYXY';

Load the database:

$ gunzip -c /tmp/myrepo.sql.gz | mysql --user myrepo --password=XYXY myrepo

Migrate EPrints

Install the version of EPrints that you want to migrate to (e.g. you may want to upgrade).

Migrate the Repository

Use tar and ssh to transfer your repository to the new server:

$ tar -czf - -C /opt/eprints3/archives myrepo/ | ssh user@mynewserver "tar -xzf - -C /opt/eprints3/archives"

Fix permissions and ownership:

$ chown -R eprints:eprints /opt/eprints3/
$ chmod -R 02775 /opt/eprints3/archives/

Migrate the Apache Configuration

If you have customised your Apache configuration you will need to transfer it:

$ scp /opt/eprints3/cfg/apache/myrepo.conf user@mynewserver:/opt/eprints3/cfg/apache/myrepo.conf
$ scp /opt/eprints3/cfg/apache_ssl/myrepo.conf user@mynewserver:/opt/eprints3/cfg/apache_ssl/myrepo.conf

Upgrading the Repository

Skip if you installed the same EPrints version

$ ./bin/epadmin upgrade myrepo

Finishing

Make sure your repository is OK:

$ ./bin/epadmin test

For example you may need to install extra dependencies.

Generate any missing Apache configuration:

$ ./bin/generate_apacheconf

Restart Apache.