#proper backup solution
15 messages · Page 1 of 1 (latest)
if you're using postgresql, this chapter its pretty good
https://www.postgresql.org/docs/current/backup.html
Thank you, but I am using MariaDB. My question is not specific about databases (those are indeed quite covered) but I am looking for a total solution: django/migration stuff included.
To backup your db, use something like mysqldump. This will include the migration records, since they are just another database table. The migration files themselves should be part of your code, i.e. they should be under version control.
It is not my code. I was hoping for a python script which would use settings.py so the db access/rights are also taken care of.
its easier, faster and more secure with the database built functionality
but if you want something from django itself, you can use fixtures
disable your signals when exporting your db or you'll have somo troubles
If you use the same database user your app is running as, db access / rights should be no issue.
You can write a management command (or just a plain Python script) that accesses your Django DB settings. In most cases I'd recommend to just read the DB information from a common source though (usually environment variables).
The idea was/is to write a plain python script within the virtenv but separate from Django and use import django.conf to parse the database settings, but that does sound more trivial than it is. So far I have not seen loading of settings.py or an indication on where my script (directory) must run so 'from django.conf import settings' will give me access to the db credentials. Of course i can grep or use a regex to parse the file, but I try to do it more pyonic
I assume it has to run from the same dir as settings.py is located, but if I run it from a higher level it does not error when importing.
All docs assume importing from within a django environment
As far as I can tell. The idea is quite basic, but I found no examples how to do something similar so far.
Why bother with python if there is db tool?