Jump to content

"Restore User Data" procedure help


Happy2Play
 Share

Recommended Posts

Since I don't really know databases, I don't understand this procedure.  Can someone break this down for someone who has no idea.  What do you enter when it ask "Please specify the database name under which you want to access the attached database"?  Where does that command go?
 

Restore User Data
 
Your user data is stored in our old library.db file, and we'll need to run some sql queries to import this into the new library.db in the new Emby Server installation. You'll need a Sqlite database editor such as DB Browser for Sqlite.
 
You'll need to open the old library.db file, then attach the new library.db file. You can then migrate the data using:


REPLACE INTO NewDB.userdata SELECT * FROM userdata
Link to comment
Share on other sites

Hi @@Happy2Play

 

Oh sure then it is easy , :P

 

Based on your posts and what I have. still one question

 

Quote from the wiki

 

Shutdown the old server instance and backup the following files and directories:

/ProgramData/config
/ProgramData/plugins
/ProgramData/data/collections
/ProgramData/data/playlists
/ProgramData/data/displaypreferences.db  /ProgramData/data/userdata_v2.db (if present)
/ProgramData/data/users.db

 

@@Luke  userdata_v2.db isn't being updated any longer and was not auto deleted (which is fine) , if it is copied over it will import again right? If so you may want to add  it as an optional step to the wiki with a warning that unless the replace is run, users and watched state etc will only be current  as the date on the file.

 

As this really isn't for the casual user.. another thought would be to add up front... That some basic familiarity with sql and SQLite tools is required to successfully complete this manually.

 

@@Happy2Play the steps to run the replace will vary based on the tool (I am most familiar with SQLite Studio). Maybe we could put together a script ?

 

 

 

Restore User Data

 

Your user data is stored in our old library.db file, and we'll need to run some sql queries to import this into the new library.db in the new Emby Server installation. You'll need a Sqlite database editor such as DB Browser for Sqlite.

 

You'll need to open the old library.db file, then attach the new library.db file. You can then migrate the data using:

REPLACE INTO NewDB.userdata SELECT * FROM userdata

Link to comment
Share on other sites

  • 2 months later...

I have followed the process and opened the old library and attached the new one, using DB Browser for SQLIte.

What do I do now with "REPLACE INTO NewDB.userdata SELECT * FROM userdata"

Where exactly do I place that text? I never used this program before.

THanks in advance

Link to comment
Share on other sites

Also when I attach the new library database, Db Browser asks me to type a database name: "Please specify the database name under which you want to access the attached database".

What name should I type?

Link to comment
Share on other sites

When I run the SQL by placing the text in the EXECUTE SQL tab, I get the following

no such table: NewDB.userdata: REPLACE INTO NewDB.userdata SELECT * FROM userdata

Link to comment
Share on other sites

BTW I have a premiere account, but my motherboard died so I had to do a clean reinstall of windows on a different hard-disk. So no way to create a backup for me..

Link to comment
Share on other sites

So I started again and this time typed NewDB when DB Browser asks me to type a database name.

It reports: "Query executed successfully: REPLACE INTO NewDB.userdata SELECT * FROM userdata (took 423ms)"

Do I need to save anything now for it to work? I clicked on Write Changes as well. I restarted emby and no favourites or watched items or even names of useres have migrated across

Link to comment
Share on other sites

So I even tried exporting the userdata table and importing it back in as suggested in

https://emby.media/community/index.php?/topic/46104-restore-user-data-emby-migration-clarification/

I get the same error message reported there:

"There is already a table of that name and an import into an existing table is only possible if the numbers of columns match".

This is so frustrating...

Link to comment
Share on other sites

Has the scan completely finished on the new setup and everything is properly identified?

Link to comment
Share on other sites

I exported and opened the old userdata table, it runs to TTK column in the spreadsheet, and the data is unintelligible to me

��!

It only contains 59 rows. Is that right?

Same number of rows (59) on the new table, but it runs only to SGZ columns.

Link to comment
Share on other sites

Deleted the table and tried importing the old one: Error importing table unrecognized token etc etc massive list error box

Link to comment
Share on other sites

Tried to plainly replace the new library file with the older one. None of the old favourites or watched movies are retained. Put the new one back in and i can see the new favorites and played items since I rebuilt the database. I am out of ideas here guys.

Link to comment
Share on other sites

I discovered that you can use Macrium Reflect to build a Windows PE bootable disc to repair any boot issues. I will build one now and switch the old hard disk back and try to repair the windows 10 installation. If that works I can install the backup plugin and fix it that way.

Link to comment
Share on other sites

  • 1 year later...
CaptainSandwich

So I started again and this time typed NewDB when DB Browser asks me to type a database name.

It reports: "Query executed successfully: REPLACE INTO NewDB.userdata SELECT * FROM userdata (took 423ms)"

Do I need to save anything now for it to work? I clicked on Write Changes as well. I restarted emby and no favourites or watched items or even names of useres have migrated across

 

I'm also  new to all this SQL stuff and have reached this point as well. My new database didn't have a 'userdata' table, so the replace command didn't intially work. After creating a userdata table in the new database, the replace command successfully ran. But, could someone please describe how this change is saved permanently to the database? After exiting dbviewer and opening the new database, the userdata table is still empty.

 

Thanks muchly. 

Link to comment
Share on other sites

I'm also  new to all this SQL stuff and have reached this point as well. My new database didn't have a 'userdata' table, so the replace command didn't intially work. After creating a userdata table in the new database, the replace command successfully ran. But, could someone please describe how this change is saved permanently to the database? After exiting dbviewer and opening the new database, the userdata table is still empty.

 

Thanks muchly. 

 

What program are you using to view the database?

 

In DB Browser for SQLite when I make changes it ask me if I want to save when database is closed/exit.  You can click "File" and select write changes (CTRL+s) also.

Link to comment
Share on other sites

Ideally you should use the "Server Configuration Backup" plugin for this .

Link to comment
Share on other sites

CaptainSandwich

What program are you using to view the database?

 

In DB Browser for SQLite when I make changes it ask me if I want to save when database is closed/exit.  You can click "File" and select write changes (CTRL+s) also.

 

I'm using DB Browser for SQLite. Ah, looks like that did the trick. It threw me a little bit by asking if I wanted to save changes to the old database file.

 

 

Ideally you should use the "Server Configuration Backup" plugin for this .

 

Yeah, after the above the results weren't quite as expected. Tried the plugin and it looks to have worked a treat.

 

Thanks!

Link to comment
Share on other sites

The new database I was importing into had a "UserDatas" table, but even after merging it didn't work (syncing up my view history). I used the plugin to restore a backup and it's the same thing, view history isn't synced. :(

 

Edit - I stand corrected! The new install created a user 'emby' - I had to switch to the user that I backed up and imported to see the view history. 

Edited by bradford
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...