Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
dump2py
: make a Python dump of a Lino database¶
- pm dump2py¶
Usage:
$ pm dump2py [options] OUTPUT_DIR
This will create a Python dump of your database in the directory
OUTPUT_DIR
.
The directory will contain a series of .py
files, one for every database
model, plus one extra file named restore.py
, which execfile()
s
the .py
files.
Options:
- --noinput¶
Do not prompt for user input of any kind.
- --tolerate¶
Tolerate database errors. This can help making a partial snapshot of a database that is not (fully) synced with the application code.
- --simulate¶
Just simulate, don’t actually write any data. This is used for verifying whether thte database structure has changed after an upgrade.
- --overwrite¶
Don’t complain if the TARGET directory already exists. This will potentially overwrite existing files.
- --max-row-count <NUM>¶
Change the maximum number of rows per source file from its default value (50000) to NUM.
See The –max-row-count option below.
This command is defined by the lino
core plugin.
The --max-row-count
option¶
When a table contains many rows, the resulting .py
file can become
so large that it doesn’t fit into memory, causing the Python process to get
killed when it tries to restore the data. To avoid this limitation,
dump2py
distributes the content over several files if a table
contains are more than NUM rows.
The default value has been “clinically tested” and should be small enough for most machines.
Hint: When your process gets killed, before using this option, consider
restarting the web services on your server and trying again. The web
services can occupy considerable amounts of memory on a long-running
production site. A simple reload_services.sh
can fix your
issue.
Glossary¶
- Python dump¶
A dump of a Lino database created using
pm dump2py
. Python dumps are used for creating daily backups or before an upgrade with data migration.
Files¶
- restore.py¶
The main script of a Python dump generated by the
pm dump2py
command.This script is run during a site upgrade.
About Python dumps¶
A database dump is an image of the data in a database which you can use e.g.
to backup and restore your data. While Django’s dumpdata
command lets
you make database dumps in json and xml format, Lino extends this by letting
you make a database dump in Python format. This is what we call a Python
dump.
To make a Python dump of your database, you use the pm dump2py
command.
This django-admin command creates a directory of Python modules with one
main module restore.py
.
To restore a dump created using pm dump2py
to your database, you execute
the restore.py
script using the pm run
command:
$ pm run mydump/restore.py
Another important thing is that you can use such a backup for data migrations.
More concrete usage exmples in The dumps demo project.