Extracting mysql database from a Nextcloud snap?

I am trying to extract the mysql database from within a Nextcloud snap. I am attempting to rescue my extra-app data which is stored in the db. I do not need a full back up of the data folder as I have this saved already.

How can I extract the database for the extra-apps folder so I can access the data stored in the db on a new snap install of Nextcloud snap?

The version I wish to extract the db from is 21.0.1.1 (28088)
The version that I wish to import the db to is 21.0.3.1 (28417)

The best person to respond would be @kyrofa, since they’re heavily involved with this snap.

I don’t know, exactly, but you should be able to find the mysql password somewhere within the snap’s files (/var/snap/nextcloud) with which you should then be able to connect to the mysql server to dump the database.

Thanks for the ping, @lucyllewy.

@professor-snap You can just dump the database directly from the snap with nextcloud.mysqldump if that’s helpful?

1 Like

@kyrofa I received an error after running nextcloud.mysqldump

mysqldump: Got error: 2002: Can’t connect to local MySQL server through socket ‘/tmp/sockets/mysql.sock’ (2) when trying to connect

I then ran sudo snap services to check if nextcloud.mysql was running

Service                    Startup  Current   Notes
nextcloud.apache           enabled  active    -
nextcloud.logrotate        enabled  inactive  timer-activated
nextcloud.mdns-publisher   enabled  active    -
nextcloud.mysql            enabled  active    -
nextcloud.nextcloud-cron   enabled  active    -
nextcloud.nextcloud-fixer  enabled  active    -
nextcloud.php-fpm          enabled  active    -
nextcloud.redis-server     enabled  active    -
nextcloud.renew-certs      enabled  active    -

Did I leave something out?

Additionally, when trying sudo nextcloud.export -b -c I get Waiting for MySQL...

Why would MySQL be waiting if the above shows enabled?

I was able to export the db by rolling back the snap version of nextcloud using the following commands:

snap revert nextcloud

This reverted the nextcloud version from 28088 to 27920 then downloaded the db with nextcloud.export -abc then backup the database.

I will not be using snap in the future.

Looks like MySQL wasn’t working on the new version. Glad you got it working with the revert enough to grab the data!