Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restoring Database #67

Closed
MyFilippo94 opened this issue Aug 4, 2021 · 3 comments
Closed

Restoring Database #67

MyFilippo94 opened this issue Aug 4, 2021 · 3 comments

Comments

@MyFilippo94
Copy link

Hello! I am a klutz and deleted my mysql database from my binded drive! Yes praise me more.

Luckily, I know I am a klutz, and had a backup ready, a couple of weeks old. So I tried putting back the folders where they are meant to be, but Ampache has still issues trying to connect to it.
I am not familiar with how to restore sql databases, nor how they work actually. Last time I had something like this happening on me (yeah it's not the first time...) I had to give up after two weeks of looking around and restart my database from scratch.

I would really really like to get my database back this time though, so this time I am asking for the help of somebody more competent than me.

Here are some probably useful informations:

Version is Ampache 4.4.3-release, running as a docker container in a Ubuntu Server OS, within a VM. It has been working as expected until I messed up.

I activated debug in the ampache.cfg.php file, the logs are full of this:

021-08-04T15:56:04+00:00 [ampache] (Dba) -> Database connection... 
2021-08-04T15:56:04+00:00 [ampache] (Dba) -> Connection failed: SQLSTATE[HY000] [2002] No such file or directory 
2021-08-04T15:56:04+00:00 [ampache] (Dba) -> Error: failed to get database handle 
2021-08-04T15:56:04+00:00 [ampache] (Dba) -> Database connection... 
2021-08-04T15:56:04+00:00 [ampache] (Dba) -> Connection failed: SQLSTATE[HY000] [2002] No such file or directory 
2021-08-04T15:56:04+00:00 [ampache] (Dba) -> Error: failed to get database handle 
2021-08-04T15:56:04+00:00 [ampache] (Dba) -> Database connection... 
2021-08-04T15:56:04+00:00 [ampache] (Dba) -> Connection failed: SQLSTATE[HY000] [2002] No such file or directory 
2021-08-04T15:56:04+00:00 [ampache] (Dba) -> Error: failed to get database handle 
2021-08-04T15:56:04+00:00 [ampache] (Dba) -> Database connection... 
2021-08-04T15:56:04+00:00 [ampache] (Dba) -> Connection failed: SQLSTATE[HY000] [2002] No such file or directory 
2021-08-04T15:56:04+00:00 [ampache] (Dba) -> Error: failed to get database handle 
2021-08-04T15:56:04+00:00 [ampache] (Dba) -> Database connection... 
2021-08-04T15:56:04+00:00 [ampache] (Dba) -> Connection failed: SQLSTATE[HY000] [2002] No such file or directory 
2021-08-04T15:56:04+00:00 [ampache] (Dba) -> Wrong dbh. 

I use Portainer to manage my docker containers, its log say this:

=> Using an existing volume of MySQL
2021-08-04 15:53:38,958 INFO Set uid to user 0 succeeded
2021-08-04 15:53:38,960 INFO supervisord started with pid 1
2021-08-04 15:53:39,962 INFO spawned: 'cron' with pid 9
2021-08-04 15:53:39,962 INFO spawned: 'inotifywatch' with pid 10
2021-08-04 15:53:39,966 INFO spawned: 'mysql' with pid 12
2021-08-04 15:53:39,966 INFO spawned: 'apache2' with pid 13
2021-08-04 15:53:40,039 INFO exited: mysql (exit status 0; not expected)
2021-08-04 15:53:41,041 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2021-08-04 15:53:41,041 INFO success: inotifywatch entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2021-08-04 15:53:41,041 INFO spawned: 'mysql' with pid 143
2021-08-04 15:53:41,041 INFO success: apache2 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2021-08-04 15:53:41,090 INFO exited: mysql (exit status 0; not expected)
2021-08-04 15:53:43,093 INFO spawned: 'mysql' with pid 266
2021-08-04 15:53:43,142 INFO exited: mysql (exit status 0; not expected)
2021-08-04 15:53:46,145 INFO spawned: 'mysql' with pid 389
2021-08-04 15:53:46,191 INFO exited: mysql (exit status 0; not expected)
2021-08-04 15:53:47,192 INFO gave up: mysql entered FATAL state, too many start retries too quickly
2021-08-04 15:54:06,464 WARN received SIGTERM indicating exit request
2021-08-04 15:54:06,465 INFO waiting for cron, inotifywatch, apache2 to die
2021-08-04 15:54:06,465 INFO stopped: apache2 (terminated by SIGTERM)
2021-08-04 15:54:06,465 INFO stopped: inotifywatch (terminated by SIGTERM)
2021-08-04 15:54:06,465 INFO stopped: cron (terminated by SIGTERM)

Three bound drives, aside from the media, are outside of the container:

drwxrwxrwx  2 www-data www-data 4096 Aug  4 15:50 config
drwxr-xr-x  2 www-data www-data 4096 Aug  4 15:53 log
drwxr-xr-x  6 www-data www-data 4096 Aug  4 16:02 mysql

And this is the content of mysql folder, mounted as /var/lib/mysql:

drwxr-xr-x 2 www-data www-data    12288 Aug  4 15:21 ampache
-rwxr-xr-x 1 www-data www-data    16384 Aug  4 15:21 aria_log.00000001
-rwxr-xr-x 1 www-data www-data       52 Aug  4 15:21 aria_log_control
-rwxr-xr-x 1 www-data www-data      976 Aug  4 15:21 ib_buffer_pool
-rwxr-xr-x 1 www-data www-data 12582912 Aug  4 15:21 ibdata1
-rwxr-xr-x 1 www-data www-data 50331648 Aug  4 15:21 ib_logfile0
-rwxr-xr-x 1 www-data www-data 50331648 Aug  4 15:21 ib_logfile1
-rwxr-xr-x 1 www-data www-data 12582912 Aug  4 15:21 ibtmp1
-rwxr-xr-x 1 www-data www-data        0 Aug  4 15:21 multi-master.info
drwxr-xr-x 2 www-data www-data     4096 Aug  4 15:21 mysql
drwxr-xr-x 2 www-data www-data     4096 Aug  4 15:21 performance_schema
-rwxr-xr-x 1 www-data www-data    24576 Aug  4 15:21 tc.log
drwxr-xr-x 2 www-data www-data     4096 Aug  4 15:21 test

going in the container with docker exec -it ampache /bin/bash I seem able to correctly read and write said folders.
Database Connection and Database Tables return an error state in /test.php.

As always I am most likely missing something obvious, but I still need your help to figure it out.
I hope opening an issue here on Github, here on the Docker-specific fork, is the right thing to do to ask help, if not please redirect me to a more suitable place. If it is...

Please help me 😄

@lachlan-00
Copy link
Member

I can help you out.

You have it saved as a SQL file? I can give you restore coanda for it. Will just be tomorrow when I'm back at my desk

If you're backing up the SQL folders I'm actually not sure how to restore that but I can test it out

@MyFilippo94
Copy link
Author

MyFilippo94 commented Aug 5, 2021

I had a backup of the whole VM drive, I haven't tried but I should be able to boot Ampache correctly from that instance.
I don't want to restore the whole VM to weeks ago, 'cause of course I did a lot of progress on other unrelated things meanwhile. I simply copied over the binded drives folders, but that resulted in this situation.
The backup VM did run fine when I tested the backup, I didn't actually check if Ampache itself was running correctly, but all services seemed working as intended. I will make sure that instance of Ampache is fully working later today.

Edit: Confirmed, previous instance is working and healthy.

@MyFilippo94
Copy link
Author

I managed in the end to solve the issue, by packing the backed-up database into a tar file, and using it as a container to preserve the permissions and ownerships, when unpacking back in the new server.
So, I think, the issue was improper ownership or permissions, during my manual file transfer procedure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants