Migrating an instance
How to migrate a running instance to a new server, with a message on the old server about the migration.
- Set up a new server (Scaleway hosting)
- Install the newest alpha release on the new server
- On the old server, if a notice about migration is wanted/needed
- Turn off tomcat
- Move the webapps folder and war-file out of the webapps folder
- Create a folder with content about the server meing migrated
- Start tomcat
- On the old server
- Move to the ROOT webapp
cd /usr/share/tomcat/webapps/ROOT
- Export the database
sudo mysqldump -p [LIVE-DB-NAME] > tslive.sql
- Move to the ROOT webapp
- On the new server
- Download the sql file on the new server, to a folder with enough space
cd /mnt/sda
wget [OLD-SERVER]/tslive.sql
- Fix naming in sql file, if the webapp changes name
sed -i 's/tslive/applive/g' tslive.sql
sed -i 's/tsbase/appbase/g' tslive.sql
sed -i 's/tstempusserva/tsapp/g' tslive.sql
- Turn off tomcat
- Import the sql file
mysql -p applive < tslive.sql
- Download the sql file on the new server, to a folder with enough space
- Connect to the new database
- Move sql functions if needed
- Fix policies
- applicationName
- applicationBasePath
- applicationServer
- Maybe:
- applicationIsBehindAReverseProxy
- applicationlPort
- applicationlPortSSL
- smtpTestMode
- securitySslPages
- If an update of the webapp version is not desired:
- On the old server
- Move the webapps war-file to the ROOT webapp folder
- On the new server
- Download the war-file
wget [OLD-SERVER]/TempusServa.war
- Replace the war-file in the webapps folder
mv TempusServa.war /usr/share/tomcat9/webapps/app.war
- Download the war-file
- On the old server
- Start tomcat on the new server
- Test the new server
- Update DNS
- If the domain is still the primary domain
- Setup SSL
- If the domain is no longer the primary domain
- Update SSL cert with old domain
- Expand nginx setup to include old domain
- If the webapp changed name
- Add a redirect app
ts install-redirectapp
- Add a redirect app
- If the domain changed
- Add a link to the new domain in the "migration webapp" on the old server
Sample migration webapp
index.jsp
Just a basic page telling the user that the server is unavailable.
<html>
<head>
<title>Sorry, we are migrating the server</title>
</head>
<body>
<h1>Sorry, the server is currently unavailable</h1>
<p>The server is currently being migrated, please check back later</p>
</body>
</html>
WEB-INF/web.xml
Remaps all requests to the server, to the index.jsp file.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Redirect TempusServa</display-name>
<servlet>
<servlet-name>index</servlet-name>
<jsp-file>/index.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>index</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>