Installation | Maintenance | Beyond Lino

Backup

You can make a Python dump of your database using the pm dump2py django-admin command that comes with Lino.

For example:

$ python manage.py dump2py 20130117

This will create a directory 20130117 with a set of ` .py` files which are a perfect representation, in Python, of your database at that moment. These files contain a complete backup of your database. You can archive the directory and send it around per email.

To restore such a dump to your database, simply pm run the restore.py script from that directory:

$ python manage.py run mydump/restore.py

Or, if you don’t use per-project manage.py files:

$ set DJANGO_SETTINGS_MODULE=myproject
$ django-admin.py run mydump/restore.py

Note that we are using here the pm run django-admin command. This makes it possible to restore your data into another project, creating a copy of your database.

Note about django-extensions

django-extensions has a command “dumpscript” which is comparable to dump2py.

The most important different is that the Python code generated by dump2py is designed in order to make it possible to write automated database migrations.

Models that get special handling

  • ContentType objects aren’t stored in a dump because they can always be recreated.

  • Site and Permission objects must be stored and must not be re-created

  • Session objects can get lost in a dump and are not stored.