Upgrading a Lino production site

This document gives generic instructions for upgrading a Lino production site to a new version. This procedure is suitable for smaller sites with one contact person. See Preview sites for are more sophisticated approach on sites with many users. See also Data migrations à la Lino for technical background information.

  • Go to your project directory:

    $ go myproject
    

    See go if you don't know that command.

  • Activate the python environment (we usually have a shell alias a which expands to . env/bin/activate):

    $ a
    
  • Stop any services that might want to write to the database (web server, supervisor):

    $ sudo service apache2 stop
    $ sudo service supervisor stop
    
  • Run make_snapshot.sh to make a snapshot of your database:

    $ ./make_snapshot.sh
    

    See Making a snapshot of a Lino database for details.

  • Run pull.sh to update the source code:

    $ pull.sh
    
  • Run the install command to install any new Python dependencies if needed:

    $ python manage.py install
    
  • Run the collectstatic command:

    $ python manage.py collectstatic
    

That's all if there is no change in the database structure. But if there was (or if you don't know whether there was) some change which requires a data migration, then you must continue:

  • Restore the snapshot:

    $ python manage.py run snapshot/restore.py
    

Note that a restore.py can take considerable time depending on the size of your database. So if you believe but are not absolutely sure there was no change in the database structure, then you can check whether you need to run restore.py by doing a second temporary snapshot and then comparing their restore.py files. If nothing has changed, then you don't need to run it:

$ python manage.py dump2py -o t
$ diff snapshot/restore.py t/restore.py
  • Stop the web server and supervisor (or whatever is appropriate on your site):

    $ sudo service apache2 stop
    $ sudo service supervisor stop
    
  • Make a snapshot of your database:

    $ ./make_snapshot.sh
    

    See Making a snapshot of a Lino database for details.

  • Update the source code:

    $ ./pull.sh
    
  • Run the collectstatic command:

    $ python manage.py collectstatic
    

    This step can often be skipped if there were no changes in the static files.

That's all if there is no change in the database structure. But if there was (or if you don't know whether there was) some change which requires a data migration, then you must continue:

  • Restore the snapshot:

    $ python manage.py run snapshot/restore.py
    

Note that a restore.py can take considerable time depending on the size of your database. So if you believe but are not absolutely sure there was no change in the database structure, then you can check whether you need to run restore.py by doing a second temporary snapshot and then comparing their restore.py files. If nothing has changed, then you don't need to run it:

$ python manage.py dump2py -o t
$ diff snapshot/restore.py t/restore.py
  • Start the web server and supervisor:

    $ sudo service apache2 start
    $ sudo service supervisor start
    

Shell scripts generated by getlino

make_snapshot.sh

Make a snapshot of the site's database.

Usage: See Making a snapshot of a Lino database.

Template: https://github.com/lino-framework/getlino/blob/master/getlino/templates/make_snapshot.sh

pull.sh

Update the Python packages used by this virtualenv.

This includes both the packages installed from cloned source code repositories and those installed via PyPI.

Template: https://github.com/lino-framework/getlino/blob/master/getlino/templates/pull.sh