mbentley / docker-teamspeak

TeamSpeak 3 Server Docker Image
69 stars 29 forks source link

Unable to keep data when updating #28

Closed LvZeeland closed 3 years ago

LvZeeland commented 3 years ago

Hey y'all, My TS3 server has been running for a year which means it's time to update. I created the docker with command: docker run -d --restart=always --name teamspeak -p 9987:9987/udp -p 30033:30033 -p 10011:10011 -p 41144:41144 -v /data/teamspeak:/data -e TS3SERVER_LICENSE="accept" teamspeak I made a snapshot before doing something as daring as updating a docker and proceeded to update. I was right to create a snapshot as all my TS data was removed when I ran docker pull teamspeak and above docker run command. I restored my snapshot and noticed that /data/teamspeak is empty. I tried manually securing the TS data with docker cp teamspeak:/data ~/Documents/TS_backup and there's a new /data folder, but there's nothing in there.

How do I update my TS server the proper way without losing my data?

mbentley commented 3 years ago

There should be nothing that would cause any data to be removed. I would have to look at the old/previous image to see what might be going on. Do you still have the previous image on your system? If so, can you do a docker images --digests and get the digest (starts with sha256 for the previous image that is over a year old) so I can take a look an inspect it?

If you still have the old container sitting around on the system, then a docker inspect <container> would be useful. The only way that I would expect that data would be missing would be if there actually wasn't a volume or it wasn't a bind mounted volume to the disk as the contents wouldn't be removed by removing the container if it was in fact using a volume as described above.

LvZeeland commented 3 years ago

Thanks for the quick reply. the SHA256 is sha256:12526f6e6f28dc8c05607c2bd9a739c7406c75a6a2ab677405a98ef7d63d5278 docker inspect teamspeak returns status as restarting (and a lot more text), might that have something to do with the issue?

mbentley commented 3 years ago

docker inspect teamspeak --format '{{json .Mounts}}' and docker inspect teamspeak --format '{{json .Config.Volumes}}'would help by showing me where the mounts & volumes are configured. docker logs teamspeak could explain what is happening about it restarting.

LvZeeland commented 3 years ago

1st command returns: [{"Type":"bind","Source":"/data/teamspeak","Destination":"/data","Mode":"","RW":true,"Propagation":"rprivate"},{"Type":"volume","Name":"d7556e3aa5811a77e5cfbdf115e844fabc6509b7e53083a396f8d4bb003ba353","Source":"/var/lib/docker/volumes/d7556e3aa5811a77e5cfbdf115e844fabc6509b7e53083a396f8d4bb003ba353/_data","Destination":"/var/ts3server","Driver":"local","Mode":"","RW":true,"Propagation":""}]

2nd returns: {"/var/ts3server/":{}}

and logs basically show the following over and over every 60 seconds: 2021-02-01 20:28:59.109764|INFO |ServerLibPriv | |TeamSpeak 3 Server 3.12.1 (2020-03-27 10:38:47) 2021-02-01 20:28:59.110043|INFO |ServerLibPriv | |SystemInformation: Linux 5.4.0-58-generic #64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020 x86_64 Binary: 64bit 2021-02-01 20:28:59.110090|INFO |ServerLibPriv | |Using hardware aes 2021-02-01 20:28:59.110376|INFO |DatabaseQuery | |dbPlugin name: SQLite3 plugin, Version 3, (c)TeamSpeak Systems GmbH 2021-02-01 20:28:59.110423|INFO |DatabaseQuery | |dbPlugin version: 3.11.1 2021-02-01 20:28:59.110616|INFO |DatabaseQuery | |checking database integrity (may take a while) 2021-02-01 20:28:59.150747|WARNING |Accounting | |Unable to open licensekey.dat, falling back to limited functionality 2021-02-01 20:28:59.150843|CRITICAL|Accounting | |The default license has expired. Please use the latest server version.

mbentley commented 3 years ago

Hmm, that's odd. It doesn't explain why stopping the container and re-deploying a new one would prevent it from working. You should be able to see the data on your host filesystem at /data/teamspeak as that is where the data is bind mounted to. Does it not exist there? It certainly should. I would expect that you can stop the existing TeamSpeak server container, remove it, and then deploy a new container with the latest image and it would pick up just fine.

LvZeeland commented 3 years ago

It is odd, isn't it? Could it be some permission error or mistake on my end? data/teamspeak is completely empty.

LvZeeland commented 3 years ago

I decided to log into portainer to see if there was anything I could do to prevent the docker from restarting thus letting me log into the docker image itself, when I noticed a second volume d7556e3aa5811a77e5cfbdf115e844fabc6509b7e53083a396f8d4bb003ba353 | /var/ts3server which leads to /var/lib/docker/volumes/d7556e3aa5811a77e5cfbdf115e844fabc6509b7e53083a396f8d4bb003ba353/_data. This folder contains: files query_ip_blacklist.txt ts3server.sqlitedb ts3server.sqlitedb-wal logs query_ip_whitelist.txt ts3server.sqlitedb-shm. I imagine this is the data that should be in /data/teamspeak, isn't it?

mbentley commented 3 years ago

Yeah, that's strange. The way that the image should work is that the entrypoint script will create symlinks for those files existing in that location back to /data. It's hard to say if the previous version that you were running was different as it very likely could have been. The old image has been removed from Docker Hub as it was pretty old so pulling the digest doesn't work anymore so I couldn't inspect it:

https://github.com/mbentley/docker-teamspeak/blob/85cbc6844142babe4b3006573fcff349e1c718f3/docker-entrypoint.sh#L21-L24

So looking at the latest in master, you should be able to pull out all of these files referenced by the entrypoint script and put them in /data/teamspeak and then run a new container from the latest image. For completeness, those files are:

query_ip_whitelist.txt
query_ip_blacklist.txt
ts3server.ini
ts3server.sqlitedb
ts3server.sqlitedb-shm
ts3server.sqlitedb-wal
.ts3server_license_accepted

Some of them like the white and black list might not exist.

LvZeeland commented 3 years ago

Alright, it being an old image must have been the problem.

Now it all works. Thanks for your help and time!

mbentley commented 3 years ago

Awesome! Glad to hear that you were able to pull the data out and get it back working!