Skip to main content

Migrating an instance

How to migrate a running instance to a new server, with a message on the old server about the migration.

  1. Set up a new server (Scaleway hosting)
  2. Install the newest alpha release on the new server
  3. On the old server, if a notice about migration is wanted/needed
    1. Turn off tomcat
    2. Move the webapps folder and war-file out of the webapps folder
    3. Create a folder with content about the server meing migrated
    4. Start tomcat
  4. On the old server
    1. Move to the ROOT webapp cd /usr/share/tomcat/webapps/ROOT
    2. Export the database sudo mysqldump -p [LIVE-DB-NAME] > tslive.sql
  5. On the new server
    1. Download the sql file on the new server, to a folder with enough space
      1. cd /mnt/sda
      2. wget [OLD-SERVER]/tslive.sql
    2. Fix naming in sql file, if the webapp changes name
      1. sed -i 's/tslive/applive/g' tslive.sql
      2. sed -i 's/tsbase/appbase/g' tslive.sql
      3. sed -i 's/tstempusserva/tsapp/g' tslive.sql
    3. Turn off tomcat
    4. Import the sql file mysql -p applive < tslive.sql
  6. Connect to the new database
    1. Move sql functions if needed
    2. Fix policies
      1. applicationName
      2. applicationBasePath
      3. applicationServer
      4. Maybe:
        1. applicationIsBehindAReverseProxy
        2. applicationlPort
        3. applicationlPortSSL
        4. smtpTestMode
        5. securitySslPages
  7. If an update of the webapp version is not desired:
    1. On the old server
      1. Move the webapps war-file to the ROOT webapp folder
    2. On the new server
      1. Download the war-file wget [OLD-SERVER]/TempusServa.war
      2. Replace the war-file in the webapps folder mv TempusServa.war /usr/share/tomcat9/webapps/app.war
  8. Start tomcat on the new server
  9. Test the new server
  10. Update DNS
  11. If the domain is still the primary domain
    1. Setup SSL
  12. If the domain is no longer the primary domain
    1. Update SSL cert with old domain
    2. Expand nginx setup to include old domain
  13. If the webapp changed name
    1. Add a redirect app ts install-redirectapp
  14. If the domain changed

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>