Move a Lino site to a new server¶
This document explains the following situation: you have a running production site on a server S1 and you want to move that site to a new server S2. You have installed S2 as described in Set up a Lino production server, so you have the same application running on both servers, maybe a newer version on S2. S1 has confidential production data while S2 has fictive demo data. You now want to copy the data from S1 to S2, migrating it on the fly as needed.
Create a snapshot with the special name
snapshot2previewon the old production site:
$ go prod $ python manage.py dump2py -o snapshot2preview
-ooption is not needed the first time, but you are likely to run this procedure several times (see General workflow below).
Create the file
restore2preview.py, which initially is just a copy of the
restore.pycreated by the
$ cd snapshot2preview $ cp restore.py restore2preview.py
You might need to edit this file e.g. if the new server has a newer version of the application. And you don’t want these edits to get overwritten in case you need to run the procedure again.
Create a file
initdb_from_prod.shin the project root of the future production server. Adapt it as needed:
PART1as this is supposed to be done on the old production server.
Run the script. This will first copy all relevant data from S1 to S2 using
rsync, then delete all data in the database on the new site and replace it with the data that has been copied from the old production site.
restore.py(third part of your
initdb_from_prod.shscript) might gives error messages e.g. when S2 has a newer version of the application and no migrators have been defined by the application developer.
In that case you should ask support of the application developer because it’s their job to specify the details of what happens during the data migration. When you get instructions to manually edit the
restore2preview.pyfile, then keep in mind that you must –of course– edit this file on the old server, as it will be mirrored to the new server.
Restart the Lino services on the new server and check whether it now has a copy of the production data. Take care to check whether uploaded files (
lino.modlib.uploads) have been copied and are available on S1.
When your manual tests pass, you inform the site operator that it’s now their turn to test the new server. There are chances that they will find more problems.
After fixing the problems, you can simply run the procedure again (create a
snapshot2preview on S1 and then run
S2). When no more problems are detected and the site operator decided to
actually move, you will run it a last time to synchronize their latest data
before stopping the old production server.