Good afternoon, I have an application in Django 1.10 in which today I need to create a backup of the bd, this copy must be made when the user clicks on a button that will be placed in a template and download the copy on the user's computer.
In my views.py I have the following.
def backup(request):
subprocess.Popen("mysqldump -u root -p12345 victimas > /home/proyecto/backup.sql")
subprocess.Popen("gzip -c /home/proyecto/backup.sql > /home/proyecto/backup.gz")
dataf = open('/home/proyecto/backups/backup.gz', 'r')
return HttpResponse(dataf.read(), mimetype='application/x-gzip')
But I get the error
[Errno 2] No such file or directory: django mysqldump
When doing it directly from the consolo I create the file, and verify the permissions of the folder.
I appreciate your cooperation