frappe / frappe_docker

Docker images for production and development setups of the Frappe framework and ERPNext
MIT License
1.52k stars 1.4k forks source link

Docker backup restore issue #1433

Closed yashwanth-t3 closed 4 months ago

yashwanth-t3 commented 4 months ago

Description of the issue

I want to restore the backup database but it is giving me error and also deletes already existing tables ( like frappe doctypes) @revant Can you please help me with this issue?

Context information (for bug reports)

I have my backup in s3 bucket and have downloaded it to the instance where I'm running my frappe docker. I want to restore this backup data to the application running inside the docker. I have to used the following commands to restore inside docker container
bench --site localhost restore /home/frappe/frappe-bench/20240710_000018-app_turiyaforms_in-database.sql or bench restore /home/frappe/frappe-bench/20240710_000018-app_turiyaforms_in-database.sql Even I have tried this with --force option which is not helping me.

I have one site create with the same app installed in the site in the frappe docker. Now, I just want to move my production data inside the docker using the backup. Before doing the restore I have checked the mariadb manually it have all the frappe doctypes (including 'tabDefaultValue') in the database. After I use the restore command it is giving me the error (mentioned below) and deleted all the tables from the database.

bench restore /home/frappe/frappe-bench/20240710_000018-app_turiyaforms_in-database.sql MySQL root password: ERROR at line 3: Unknown command '\-'. Table 'tabDefaultValue' missing in the restored site. Database not installed correctly, this can due to lack of permission, or that the database name exists. Check your mysql root password, validity of the backup file or use --force to reinstall

The mariadb image used is mariadb:10.6

I have tried the solution like (https://discuss.frappe.io/t/table-tabdefaultvalue-missing-error-when-creating-new-site/78019/17)

  1. Changed 50-server.cnf

[mysqld] innodb_read_only_compressed = FALSE

  1. SET GLOBAL innodb_default_row_format=DYNAMIC;

Still facing the same issue. Can't restore the old backup data.

Steps to reproduce the issue

  1. Create a site in frappe using docker. Just as mentioned in https://github.com/frappe/frappe_docker/blob/main/pwd.yml
  2. Take a backup using bench --site {site} backup --with-files
  3. Use the backup file and restore command to restore the database bench restore [OPTIONS] SQL_FILE_PATH

Observed result

After the restore command the database tables are deleted. Even the default frappe doctype is deleted.

Expected result

Want to restore the backup data and use in the site running in docker.

Stacktrace / full error message if available

bench restore /home/frappe/frappe-bench/20240710_000018-app_turiyaforms_in-database.sql
MySQL root password:
ERROR at line 3: Unknown command '\-'.
Table 'tabDefaultValue' missing in the restored site. Database not installed correctly, this can due to lack of permission, or that the database name exists. Check your mysql root password, validity of the backup file or use --force to reinstall
letajmal commented 4 months ago

check line 3 of your sql file and remove the escape character '\'

yashwanth-t3 commented 4 months ago

Imported the backup database data by running the following command inside the backend-container mysql -u root -p -h --force < SQL FILE bench migrate

For importing the public and private file, Extract the file and place the files inside the site public and private files respectively.

https://medium.com/@yashwanthtss7/dockerize-custom-application-in-frappe-framework-migration-from-vm-to-container-bac073ec1040

dawoodjee commented 4 weeks ago

Downgrade to mariadb 10.3

Reference to Revant's forum entry

I also managed to get past the issue by uppdating frappe