Backup Database Issues

Nextcloud version (eg, 10.0.2): 11.0
Operating system and version (eg, Ubuntu 16.04): 16.04 server
Apache or nginx version (eg, Apache 2.4.25): Apache 2
PHP version (eg, 5.6): PHP 7.
Using SSH Keys for SSH with login using password turned off.

The issue you are facing:

I cannot successfully backup the database for nextcloud. When I try to run:

mysqldump --lock-tables -h [server] -u [nextcloud] -p[xxxxxxxx] [nextcloud] > nextcloud-sqlbkp_date +"%Y%m%d".bak

I get this

mysqldump: Got error: 1045: Access denied for user ‘[nextcloud]’@‘localhost’ (using password: YES) when trying to connect

is this because I have disabled the login with password and using SSH keys instead? I wouldnt think that would affect it but I`m not sure.

The username, password, database name are all correct as they match what is in the config.php file.

I am leaving the brackets and entering the information inside them, I have tried without the brackets. I have tried a few things but I cannot get this to work for whatever reason.

also do I need to be cd into the nextcloud dir before I run this or does it matter?

Thanks for any information about this.

EDIT:

I found this

mysqldump -u root -p mydbscheme > mydbscheme_dump.sql

When I run this it does ask for a password and makes a 13M file. But I am not sure if this is a good way to do it. I am pretty sure that the --lock-tables would be needed… as its in the original backup code.

A good way to verify your backup is to try to restore the tables in a different database or different host. This way, you also know how to do it and you can note it somewhere in case you need it one day.

You can’t use the --lock-tables with your mysqldump-command? You can also set NC in maintenance mode, then it shouldn’t do any operations on the database.