Docker database recovery

I have SQL backup of my previous installation which was version 11 now I would like to restore the database to new docker installation of version ERPNext: v12.10.0 (version-12).

I tried logging into mariadb container and doing a mysqldump based restore it didn’t work.
Data was not reflected in erpnext

Help is appreciated

Steps:

  • create a new site
  • check site/site_config.json for db_name and db_password
  • get into mariadb shell
  • show databases, find the db_name here.
  • drop database `db_name`; create database `db_name`;

Commands:

use mariadb shell:

docker exec -it <project>_mariadb_1 mysql -uroot -p$MARIADB_ROOT_PASSWORD

restore db:

docker exec -it _mariadb_1 mysql -uroot -p$MARIADB_ROOT_PASSWORD db_name < db_name-database.sql
docker exec -i <project>_mariadb_1 mysql -uroot -p$MARIADB_ROOT_PASSWORD --database=db_name < db_name-database.sql

Notes:

  • there is no space between -p and $MARIADB_ROOT_PASSWORD.
  • db_name-database.sql exists on host machine.
  • run migrate to ensure db it patched
  • copy encryption_key if it exists from old site_config.json to new site_config.json

Can you please elaborate how to do these things on docker, which container bash to login into ?

  • create a new site
  • check site/site_config.json for db_name and db_password

As mentioned earlier I had logged into the maraidb container and done the mysql restore as described by you , but site didn’t display anything eventually I had to reinstall everything.

Also Please make a provision for letsencypt to be bypassed if site has already go the certificate.During installation I need to reinstall a couple of times which cause rate limit issue for letsencypt.

With regards
Deepak

~/frappe-bench/sites/site.name.com needs to resolve by DNS.
Check container logs.

It should be

docker exec -i <project>_mariadb_1 mysql -uroot -p$MARIADB_ROOT_PASSWORD --database=db_name < db_name-database.sql

the “-it” give error message “the input device is not a TTY”, and --database= is more friendly with marriadb documentation.

But thank’s, I was struggling with bench restore in docker that do not work : yes, I know RTFM :sweat_smile:
bench do not work into docker production deployment.

1 Like