mikiher / audiobookshelf-windows

Installs and manages Audiobookshelf on Windows
72 stars 1 forks source link

Migrating server data from an existing Docker installation #3

Open lemendoza956 opened 10 months ago

lemendoza956 commented 10 months ago

I have the docker version and created a backup. When I restored it on your windows version it doesn't restore the book cover images. I don't have many audiobooks but I would still have to go one by one and match the books to restore the book covers.

mikiher commented 10 months ago

I am pretty sure what you did is not supported at the moment.

I believe the docker version database contains paths to covers in the docker directory space (even if they map to windows folders). When you restore a backed up version of that into your Windows install (which knows nothing about docker), those paths do not exist, so images cannot be restored.

What you're requesting seems to be a valuable feature. I'm not sure how easy it is to implement (also possible that I'm all wrong about this, and it's a very easy fix).

@advplyr what do you think?

advplyr commented 10 months ago

The paths to your library folders would need to be exactly the same or it will not work, so in other words you cannot do what you are trying to do without manually updating all of the file paths in the database.

I don't think this is something we will be supporting since how would we know what file paths to use?

You can do this yourself though and maybe if you can write some good SQL queries it wouldn't be too difficult.

It's not just the images that won't work, you won't be able to play the audio files either since those file paths will also be incorrect.

mikiher commented 10 months ago

The paths to your library folders would need to be exactly the same or it will not work, so in other words you cannot do what you are trying to do without manually updating all of the file paths in the database.

I don't think this is something we will be supporting since how would we know what file paths to use?

in abswatcher, I obtained the mapping between docker and windows folders programmatically by inspecting the audiobookshelf docker container. A similar approach can be used here.

You can do this yourself though and maybe if you can write some good SQL queries it wouldn't be too difficult.

I might get to write this docker-to-windows audiobookshelf migration tool at some point - as I said, it would be a valuable feature to have, since up until now docker was the recommended option for installing on Windows, and I'm sure many people have large docker based config and metadata directories.

I don't believe I will get to this soon, though.

It's not just the images that won't work, you won't be able to play the audio files either since those file paths will also be incorrect.

advplyr commented 10 months ago

It will be nice to offer as an external script but I don't think it should be part of the server. Possibly part of the Windows tray app if it is possible to add in a clean way.

mikiher commented 10 months ago

Agreed, that's what I meant.

anakinsleftleg commented 8 months ago

This would be great, since the tools to create MB4 files and do metadata embedding and chapter editing (actually I haven't checked if these are in the Windows version), are only in the docker version and are great tools. So managing all the audio files there, and then eventually importing the database into the Windows version would be ideal.

GamerMagic12 commented 5 months ago

Using the built-in "Find and Replace All" tool in SQLite Browser, I migrated all old Docker file paths to the new Windows paths by simply updating the beginning of each path. This allowed me to transfer all user progress and all the other data. It took at most like 5mins and was super easy.

L0bsang commented 1 month ago

Using the built-in "Find and Replace All" tool in SQLite Browser, I migrated all old Docker file paths to the new Windows paths by simply updating the beginning of each path. This allowed me to transfer all user progress and all the other data. It took at most like 5mins and was super easy.

Thank you. This helped me out today. Took a bit of time to figure out but I was able to recover everything after moving to windows from docker by replacing the paths. Used DBeaver to search and DB Browser to replace. First time didn't work, but probably due to the wrong type of slash. Second time worked great.

kanine commented 10 hours ago

This is how I did it, I may have missed some areas but the library has been working fine after making the following changes with sqllite3. Download that here: https://www.sqlite.org/download.html

I've just left my paths as a working example, so change these paths according to your own setups. If you have more than one library folder just repeat the update statements. I don't use podcasts so there could be more tables that need updating if you do.

Steps

  1. Backup your docker based instance
  2. Restore to your audiobookshelf-win instance
  3. Stop the audiobookshelf-win server
  4. Excute the SQL Commands below
  5. Start the audiobookshelf-win server
D:\Apps\sqlite-345\sqlite3.exe D:\AppData\AudioBookShelf\config\absdatabase.sqlite

-- Show current paths in library config and change paths below according to your setup
select path from libraryfolders;

UPDATE libraryfolders
SET path = REPLACE(path, '/audiobooks-share', 'Y:/VMs/AudioBookLibrary');

UPDATE libraryitems
SET path = REPLACE(path, '/audiobooks-share', 'Y:/VMs/AudioBookLibrary'),
    libraryfiles = REPLACE(libraryfiles, '/audiobooks-share', 'Y:/VMs/AudioBookLibrary');

UPDATE books
SET coverPath = REPLACE(coverPath, '/audiobooks-share/', 'Y:/VMs/AudioBookLibrary/');

UPDATE books
SET ebookfile = REPLACE(ebookfile, '/audiobooks-share/', 'Y:/VMs/AudioBookLibrary/')
WHERE ebookfile is not null;

.quit

I had limited success with UNCs so just went with a mapped drive in the end for simplicity, also note that forward slashes are preferred for the Windows folder names.

mikiher commented 6 hours ago

That doesn't seem to be a full solution (it misses some tables, which in your case may have been empty).

I'd advise anyone who tries using this solution to keep a backup copy of the database before attempting this - it is quite a dangerous operation and you may hit some delicate unforseen issues.

I am sorry I haven't found the time to complete the code for doing this. I have a working version but I have not tested it enough to be released for the general audience. This will have to wait a bit more.