Skip to content
This repository has been archived by the owner on Apr 12, 2021. It is now read-only.

Commit

Permalink
http://luc.lino-framework.org/blog/2019/1109.html
Browse files Browse the repository at this point in the history
  • Loading branch information
lsaffre committed Nov 9, 2019
1 parent 5010f32 commit d0e7a7e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 48 deletions.
39 changes: 6 additions & 33 deletions docs/admin/shell_scripts.rst
Expand Up @@ -5,48 +5,21 @@
Shell scripts to be used on a production site
=============================================

The following files are designed as templates to be copied to every
Lino project directory and to be edited in order to adapt them to
your system environment.

.. xfile:: make_snapshot.sh

Make a snapshot of the project database.

Usage: See :ref:`admin.snapshot`.

Template: :srcref:`/bash/make_snapshot.sh`

Installation notes:

When you have tested this script, you can add a file
:file:`/etc/cron.d/lino_backup` to run it every day at **6h33**::
# Backup Lino database (Python dump) once a day
# m h dom mon dow user command
33 6 * * * www-data /path/to//mysite/make_snapshot.sh



.. xfile:: pull.sh

Update the source code repositories used by this project.

Usage: see :ref:`admin.upgrade`.
See also :xfile:`make_snapshot.sh` and :xfile:`pull.sh`.

The following files are designed as templates to be copied to a Lino project
directory and to be edited in order to adapt them to your system environment.

.. xfile:: import_sepa.sh

Import bank statements to Lino (for applications that use
:mod:`lino_xl.lib.b2c`).

Installation notes:

When you have tested this script, you can add a file
:file:`/etc/cron.d/import_sepa` to run it e.g. every 30 minutes on
workdays during office time::

# m h dom mon dow user command
15,45 7-18 * * 1-5 www-data /path/to/mysite/import_sepa.sh


52 changes: 37 additions & 15 deletions docs/admin/upgrade.rst
Expand Up @@ -22,28 +22,30 @@ are more sophisticated approach on sites with many users. See also

$ a

- Stop the web server and supervisor::
- Stop any services that might want to write to the database (web server,
supervisor)::

$ sudo service apache2 stop
$ sudo service supervisor stop

Or whatever is appropriate on your site.
- Make a snapshot of your database::
- Run :xfile:`make_snapshot.sh` to make a snapshot of your database::

$ ./make_snapshot.sh

See :doc:`/admin/snapshot` for details.

- Update the source code::
- Run :xfile:`pull.sh` to update the source code::

$ ./pull.sh
$ pull.sh

- Run the :manage:`install` command to install any new Python dependencies if needed::

$ python manage.py install

- Run the :manage:`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:
Expand All @@ -58,20 +60,19 @@ absolutely sure there was *no change* in the database structure, then
you can check whether you need to run :xfile:`restore.py` by doing a
second temporary snapshot and then comparing their :xfile:`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::
- Stop the web server and supervisor (or whatever is appropriate on your site)::

$ sudo service apache2 stop
$ sudo service supervisor stop

Or whatever is appropriate on your site.

- Make a snapshot of your database::

$ ./make_snapshot.sh

See :doc:`/admin/snapshot` for details.
Expand All @@ -86,7 +87,7 @@ files. If nothing has changed, then you don't need to run it::

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:
Expand All @@ -101,7 +102,7 @@ absolutely sure there was *no change* in the database structure, then
you can check whether you need to run :xfile:`restore.py` by doing a
second temporary snapshot and then comparing their :xfile:`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

Expand All @@ -112,3 +113,24 @@ files. If nothing has changed, then you don't need to run it::
$ sudo service supervisor start


Shell scripts generated by getlino
==================================


.. xfile:: make_snapshot.sh

Make a snapshot of the site's database.

Usage: See :ref:`admin.snapshot`.

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


.. xfile:: pull.sh

Update the Python packages used by this :term:`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

0 comments on commit d0e7a7e

Please sign in to comment.