Django MySQL database backup and restore to new server

142 views
Skip to first unread message

marc bellazzini

unread,
May 4, 2020, 5:53:29 PM5/4/20
to Django users
Hello, 

I have Django 2.x running on an old Ubuntu server with a MySQL database. I have installed a new Ubuntu 20.04 server on another machine with Django 3.x and MySQL. I would like to backup the old Django/mysql database and restore it on the new server. What is the best practice for doing this? 

Thanks

Marc
 
Message has been deleted

marc bellazzini

unread,
May 5, 2020, 12:24:12 PM5/5/20
to Django users
SOLVED

# after more extensive googling .....

ORIGINAL SERVER
- cd to your web project directory
- python manage.py dumpdata > db.json

NEW SERVER
- sftp db.json file to new server web project directory
- python manage.py migrate
- python manage.py shell
-- >> from django.contrib.contenttypes.models import ContentType
-- >> ContentType.objects.all().delete()
-- >> quit()
- sftp db.json file to new server web project directory
- python manage.py loaddata db.json

mcaay

unread,
Jul 28, 2020, 6:08:21 PM7/28/20
to Django users
Thanks a lot! Solved my 

django.db.utils.IntegrityError: Problem installing fixture ... duplicate key value violates unique constraint

problem :)
Reply all
Reply to author
Forward
0 new messages