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

Migrating server data from an existing Docker installation #3

Open
lemendoza956 opened this issue Jan 6, 2024 · 11 comments
Open

Migrating server data from an existing Docker installation #3

lemendoza956 opened this issue Jan 6, 2024 · 11 comments

Comments

@lemendoza956
Copy link

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
Copy link
Owner

mikiher commented Jan 6, 2024

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
Copy link
Collaborator

advplyr commented Jan 6, 2024

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
Copy link
Owner

mikiher commented Jan 6, 2024

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
Copy link
Collaborator

advplyr commented Jan 6, 2024

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
Copy link
Owner

mikiher commented Jan 7, 2024

Agreed, that's what I meant.

@mikiher mikiher changed the title Restoring backup missing images Migrating server data from an existing Docker installation Jan 10, 2024
@anakinsleftleg
Copy link

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
Copy link

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
Copy link

L0bsang commented Oct 14, 2024

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
Copy link

kanine commented Nov 23, 2024

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 audioFiles = REPLACE(audioFiles, '/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;

UPDATE authors
SET imagepath = REPLACE(imagepath, '/metadata/authors/', 'D:/AppData/AudioBookShelf/metadata/authors/')
WHERE imagepath is not null;

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

.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
Copy link
Owner

mikiher commented Nov 23, 2024

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.

@kanine
Copy link

kanine commented Nov 23, 2024

That doesn't seem to be a full solution

I had missed Authors, and didn't take Podcasts into consideration as I don't use that function. I've updated the earlier post.

Update: Found a couple more places and added to the previous post.

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

7 participants