Continuing the discussion from Database restore (force):
it is mentioned in the linked Topice to add a
-f flag to the bench restore command. However as per now (may 2019) the
-f option does not exists in the
bench restore command (anymore)
/frappe-bench$ bench restore [/path/to/opt/bench/20190521_122303-mysite.local-database.sql.gz -f
Usage: bench restore [OPTIONS] SQL_FILE_PATH
Try "bench restore --help" for help.
so, how do I force it?
What I am doing at the moment is dropping the existing db first which works but is a multi-step procedure instead of a on-stop-shop.
bench --site site.Name --force restore /path/to/backup.sql
If I understand the question.
I agree with @smino
The command switches can be in any order ( I habitually put --force before --site) as long as they both are in the command you should have no problems.
P.S. I have never been able to get a -f to work, but that may just be me so I always use --force.
There was also an extreme case where I had to use “sudo bench --force --site …” but I cannot remember what that situation was. I just bring it up because it also works in case you get stumped by some other strange error.
In case you are facing problems with large MySQL files, use the mysql command to import your database.
mysql -u root -p databse_name < database.sql
I heard this before (I think @bkm here also favors direct mysql commands over
bench restore) but also contradictory statements in the line of,
bench restore would trigger the exact same
mysql -u root -p databse_name < database.sql in the background, just looking different from the front.
thus far (with yet very small databases) I have not seen a single problem with restoring via
It is when the database gets pretty large that you will see some errors about mysql losing sync with the server, but it always happens at the end as it is trying to wrap up and the restore is actually complete and good.
I get the error on one database in particular that is already 1.8gb in size and it only happens when using the bench restore command. No error if I use the direct mysql command. Go figure.