Migrate Video Station Database

Questions about using 3rd party Media Streaming software may go here
Forum rules
We've moved! Head over to Synology Community (community.synology.com) to meet up with our team and other Synology enthusiasts!
ammulder
I'm New!
I'm New!
Posts: 2
Joined: Tue Jun 16, 2015 3:11 pm

Migrate Video Station Database

Unread post by ammulder » Tue Jun 16, 2015 3:31 pm

I just upgraded both hard drives in a DS214play to bigger ones. I did a backup and restore to the new drives to get all the files and configuration moved over. But it lost all the video station data (which was extensively tweaked). I installed video station on the new drives and waited for indexing to finish to be sure, but the result was a mess -- images missing, episodes of TV shows separated into listings for different shows, and all that.

In order to recover, I shut down and put the old drives in, attached a USB drive, turned on ssh, ssh'd to the DS, and ran this to create a backup file of the video station database:

Code: Select all

pg_dump -U postgres -Fc -b -f /volumeUSB1/usbshare/videostation.dump video_metadata
(the name of the USB volume after the -f parameter may vary, or you can replace that with any destination file you like)

Then I shut down, put the new hard drives in (I had already run the initial restore to them), attached the USB drive, and started the DS again. I stopped video station, ssh'd in, and ran this to replace the video station database full of crap with all the info from the old drives:

Code: Select all

pg_restore -U postgres -c -d video_metadata /volumeUSB1/usbshare/videostation.dump
Again, the final path there should point to the database backup you created before, so the specific location may vary. The restore command gave a bunch of errors like this but they didn't seem to matter (I assume the specific object IDs just changed):
pg_restore: [archiver (db)] Error from TOC entry 2267; 2613 17072 BLOB 17072 postgres
pg_restore: [archiver (db)] could not execute query: ERROR: large object 17072 does not exist
Command was: SELECT pg_catalog.lo_unlink('17072');
Then I started video station again. It seems to have worked as desired -- all my shows and movies are listed again properly and their images are back.

For what it's worth this was with DSM 5.2-5565 Update 2 which uses PostgreSQL 9.3.6. I wouldn't have a lot of confidence it would work across different DSM versions (since they may have changed the database layout), but both old and new drives were on the same DSM version at the time I did it.

Squozen
Guru
Guru
Posts: 1561
Joined: Wed Jan 09, 2013 1:35 am

Re: Migrate Video Station Database

Unread post by Squozen » Fri Dec 11, 2015 11:01 pm

Thanks for this. You've saved me some experimentation time! :mrgreen:

Just wanted to let you know that somebody appreciated your post.

paradeiser
Experienced
Experienced
Posts: 120
Joined: Mon Aug 09, 2010 10:57 am

Re: Migrate Video Station Database

Unread post by paradeiser » Wed Aug 03, 2016 1:41 pm

I just found your post and hoped it could help me to move my Video Station database to a new (restored) Synology.

But I get this error while trying to dump the data on a share on my old NAS

Code: Select all

pg_dump: [archiver (db)] connection to database "video_metadata" failed: FATAL:  Peer authentication failed for user "postgres"
i logged in via SSH as admin

DSM 6.0.1-7393 Update 2

any ideas? thanks a lot!
sincerly,
marko
DS210j | DS410 | DS211 | DS214 | DS216+II | DS916+ | Back-UPS | macOS/Windows

mathiasi
I'm New!
I'm New!
Posts: 2
Joined: Thu Aug 11, 2016 10:31 pm

Re: Migrate Video Station Database

Unread post by mathiasi » Thu Aug 11, 2016 10:33 pm

paradeiser wrote:I just found your post and hoped it could help me to move my Video Station database to a new (restored) Synology.

But I get this error while trying to dump the data on a share on my old NAS

Code: Select all

pg_dump: [archiver (db)] connection to database "video_metadata" failed: FATAL:  Peer authentication failed for user "postgres"
i logged in via SSH as admin

DSM 6.0.1-7393 Update 2

any ideas? thanks a lot!
sincerly,
marko
There should be a simple fix - After DSM 6, such commands should be run with sudo in front of the command in order to run as super user.

paradeiser
Experienced
Experienced
Posts: 120
Joined: Mon Aug 09, 2010 10:57 am

Re: Migrate Video Station Database

Unread post by paradeiser » Fri Aug 12, 2016 9:50 am

thanks a lot for the hint!

Eventually I figured out to try it as su (cant rercall the exact command… su -i or something like that) - which let me dump the database.
But as described before the import resulted in a lot of error messages. The end-result in VideoStation was very unsatisfying: Actually just the names of my personal libraries were restored, but no index, tags, artwork, watch-lists, etc. etc. this was all lost.
I ended up reinstalling VideoStation with a blank database and do it all from scratch :(
DS210j | DS410 | DS211 | DS214 | DS216+II | DS916+ | Back-UPS | macOS/Windows

cris73
I'm New!
I'm New!
Posts: 1
Joined: Sat Oct 08, 2016 8:44 am

Re: Migrate Video Station Database

Unread post by cris73 » Sat Oct 08, 2016 8:47 am

Just for the sake of other user who may have similar issue I used the command you posted prior upgrading between v.6 and another v,6 patch which i noticed wipe out the video station DB, had to use the sudo as suggested in the thread and the restore throw out a bunch of errors, but the result was satisfactory and I have my DB fully restored

User avatar
kpo
Student
Student
Posts: 66
Joined: Thu Jun 06, 2013 1:32 pm

Re: Migrate Video Station Database

Unread post by kpo » Thu Feb 23, 2017 6:37 pm

Hey guys is this procedure different from "Exporting metadata info" as described in here https://www.synology.com/en-global/know ... n/metadata ?
Synology DS213
WD Red 3Tb HDD
WD Red 6Tb HDD
Tp-Link TL-WDR4300
Foscam FI-9805W
WDTV Live (WDLXTV)
Rikomagic V5

PhoenixNL72
Trainee
Trainee
Posts: 14
Joined: Mon Nov 20, 2017 7:13 am

Re: Migrate Video Station Database

Unread post by PhoenixNL72 » Mon Nov 27, 2017 10:33 am

to kpo:
Yes this is very different. The export mentioned in the knowledgebase article is refering to videostations own export which exports the meta data per video file to a file with the extension vsmeta added. Those files are put in the same directory as the original video file (you can see them in file station or over a samba/windows share).
What the export command pg_dump does is export the raw information from the internal database (postgresql) to a file. Which allows you to later manually restore it if something messes up the database.
You could even delete the database (for instance if it has become corrupted) and recreate it from scratch using that backup file.

(The vsmeta export videostation makes is kinda hit or mis. If you move the folder with the video and vsmeta files in it, videostation should read the information (including covers) from the vsmeta files instead of researching them on the internet. However in my experience this doesn't always work properly. Also if you manually alter metadata for a video in video station it isn't copied over to the corresponding vsmeta file, you'd have to do a reexport for that. Synology claims changes are copied to the vsmeta file but that is not what I have experienced myself sofar.)

PhoenixNL72
Trainee
Trainee
Posts: 14
Joined: Mon Nov 20, 2017 7:13 am

Re: Migrate Video Station Database

Unread post by PhoenixNL72 » Mon Nov 27, 2017 10:44 am

BTW if anyone is interrested, I've created a little script that is called from the synology Task scheduler, that automatically makes a backup of the postgres media and video databases:
(Make sure you enter this in vi using SSH. Windows notepad will add windows control characters to the command lines and the synology script engine does not understand those which results in errors and no backup files.)
Usage: Set _path to the location you want the backup files to be placed/ In my case they are stored in the Shared folder "Backup" in a subfolder "_Videostation(MetaData)".
The _now variable stores the current data in a year-month-data format so yuo can have a different backup per day.
To restore from this backup I use the following commands in an SSH session(after cding to the backup folder)
gunzip < <date>_mediaserver-backup.sql.gz | psql -U postgres mediaserver
gunzip < <date>_video_metadata-backup.sql.gz | psql -U postgres video_metadata
(The "psql -U postgres" part changes the user to postgres)

Filename BackupMetaDataDBs.sh:
_now=$(date +"%Y-%m-%d")
_path="/volume1/Backup/_Videostation(MetaData)"
echo "Starting videostation metadata backup to $_path..."
echo $_path
cd "$_path"
pg_dump -O -U postgres mediaserver | gzip > $_now\_mediaserver-backup.sql.gz
echo "Generated $_now\_mediaserver-backup.sql.gz..."
pg_dump -O -U postgres video_metadata | gzip > $_now\_video_metadata-backup.sql.gz
echo "Generated $_now\_video_metadata-backup.sql.gz..."

jacekplacek
I'm New!
I'm New!
Posts: 1
Joined: Sat Mar 31, 2018 12:15 am

Re: Migrate Video Station Database

Unread post by jacekplacek » Sat Mar 31, 2018 12:18 am

Works like a charm @ammulder. Thanks for these commands!

dzilupl
I'm New!
I'm New!
Posts: 1
Joined: Mon May 14, 2018 12:55 pm

Re: Migrate Video Station Database

Unread post by dzilupl » Thu May 17, 2018 9:51 am

Is there any chance to copy to another Synology VideoStation information about progress of watching programs for users? I've moved database from one DS216play to another DS218play, everything is the same but there is no info about which movies are watched etc.

Locked

Return to “Media Streaming Mods”