.. _backup: ====== Backup ====== You can make a Python dump of your database using the :manage:`dump2py` :term:`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 :manage:`run` the :xfile:`restore.py` script from that directory:: $ python manage.py run mydump/restore.py Or, if you don't use per-project :xfile:`manage.py` files:: $ set DJANGO_SETTINGS_MODULE=myproject $ django-admin.py run mydump/restore.py Note that we are using here the :manage:`run` :term:`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 :mod:`dump2py `. The most important different is that the Python code generated by :mod:`dump2py ` is designed in order to make it possible to write automated :ref:`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.