Updating Media Indexes on Synology NAS: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
No edit summary
Tag: wikieditor
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:NAS]] [[Category:Production]]
== DSM 7 ==
== Goal ==
 
=== Scenario ===
 
'''Synology Photos''' is not showing some image files and/or some directories within the `/Photo` or `/Photos` directories.
 
=== Resolution ===
 
First try renaming the directory, e.g. `missing-photos` to `missing-photos-a`. Then refresh the view in '''Synology Photos'''. This usually works to force Synology Photos to recognize a missing directory's existence.
 
If photos are still missing, re-index the photos directory: '''Synology Photos''' > '''Account''' > '''Settings''' > ''(choose between '''Personal''' or '''Shared''' tabs)'' > '''Indexing''' > click the '''Re-Index''' button.
 
'''SP''' will display "indexing..." next to the button. Re-indexing may take a while. I have not found any articles describing a way to watch the progress of the indexing. The only indication that the process has completed is waiting for the "indexing..." message to go away.
 
== DSM 6 and previous (ARCHIVED) ==
 
<p class="alert alert-warning">The following information refers to previous versions of DSM (prior to DSM 7) and are saved for archival purposes</p>
 
=== Goal ===


Files are saved to a Windows 7 directory.  
Files are saved to a Windows 7 directory.  
Line 10: Line 27:
How to re-index NAS so the files are available in Photo Station before the nightly indexing.
How to re-index NAS so the files are available in Photo Station before the nightly indexing.


== Enable the command line on NAS ==
=== Log on to NAS with SSH ===
 
See [[Enable SSH on Synology NAS]]
 
=== Re-index media files ===


* Log in to DSM.
<div class="alert alert-warning">TODO: Research the differences between command line re-indexing and re-indexing through the DSM Control Panel. I think they do the same thing. If that's the case, using the DSM is easier.</div>
* Enable SSH
** Open the '''Terminal Services''' Menu, from the '''Network Services''' Folder
** Enable the '''SSH''' Service.
** Click '''OK'''.
* Grant remote access.
** Open the '''Firewall''' Menu, from the '''Network Services''' Folder
** Double click enabled rule
** In '''Ports''' Section, press '''Select''' button next to Select from a list of built-in applications
** Make sure Port 22 (SSH) is enabled
** Click '''OK''' twice and then '''Save'''.<ref>[http://forum.synology.com/wiki/index.php/Enabling_the_Command_Line_Interface Enabling the Command Line Interface] (Synology Wiki)</ref>


== Re-index media files ==
==== Command line ====


* SSH to NAS server
SSH to NAS server
* Navigate to the directory to be re-indexed<br /><pre>$ synoindex -R dirpath</pre>
<syntaxhighlight lang="bash">
* `synoindex -h` for all command line options.<ref>[https://codesourcery.wordpress.com/2012/11/29/more-on-the-synology-nas-automatically-indexing-new-files/ More on the Synology NAS Automatically Indexing New Files] ("codesourcery" blog, 11/29/2012)<br />''This includes a Python script for watching for file system changes and triggering the `synoindex` command.''
usage:
    Add:    synoindex -a filename
    Delete: synoindex -d filename
    Add folder:    synoindex -A folder
    Delete folder: synoindex -D folder
    Rename/move file/folder:    synoindex -N newfullpath oldfullpath
    Update Photo Images:        synoindex -U photo
    Get from DB:        synoindex -g filename -t [video|music|photo|playlist]
</syntaxhighlight>
 
Additionally, this command will re-index a specific media table:<ref>[http://wacha.ch/wiki/synology Synology Indexing] - Synology Wiki by Clemens Wacha</ref>
 
<syntaxhighlight lang="bash">
synoindex -R [video|music|photo|playlist|all]
</syntaxhighlight>
 
`synoindex -h` for all command line options.<ref>[https://codesourcery.wordpress.com/2012/11/29/more-on-the-synology-nas-automatically-indexing-new-files/ More on the Synology NAS Automatically Indexing New Files] ("codesourcery" blog, 11/29/2012)<br />''This includes a Python script for watching for file system changes and triggering the `synoindex` command.''</ref>
 
`synoindex` can be used to retrieve metadata from indexed files.
 
==== Synology DSM ====
 
* Login to the DSM with an account with administrator priviledges.
* '''Control Panel''' > '''System''' > '''Media Indexing''' > '''Media Indexing''' tab > '''Re-index''' button.
* It will report '''Indexing media files''', which is a slow process.
 
=== Checking on the current indexes ===
 
Use the postgreSQL interactive terminal:<ref>[http://wacha.ch/wiki/synology Synology Indexing] - Synology Wiki by Clemens Wacha</ref>
 
<syntaxhighlight lang="bash">
DiskStation> sudo psql mediaserver postgres
</syntaxhighlight>
 
To display a list of tables:
 
<syntaxhighlight lang="sql">
mediaserver=# \dt
        List of relations
Schema |  Name    | Type  | Owner
--------+-----------+-------+-------
public | directory | table | admin
public | music    | table | admin
public | photo    | table | admin
public | playlist  | table | admin
public | video    | table | admin
(5 rows)
</syntaxhighlight>
 
To check the current number of indexed files:
 
<syntaxhighlight lang="sql">
select count(1) as music_count from music;
select count(1) as photo_count from photo;
select count(1) as video_count from video;
</syntaxhighlight>
 
To view the last file indexed:
 
<syntaxhighlight lang="sql">
select * from photo where id = (select max(id) from photo);
</syntaxhighlight>
 
To quit type
 
<syntaxhighlight lang="sql">
\q
</syntaxhighlight>


== Notes ==
== Notes ==
<references />
<references />
[[Category:Synology]] [[Category:Production]]

Latest revision as of 21:21, 29 November 2022

DSM 7[edit]

Scenario[edit]

Synology Photos is not showing some image files and/or some directories within the /Photo or /Photos directories.

Resolution[edit]

First try renaming the directory, e.g. missing-photos to missing-photos-a. Then refresh the view in Synology Photos. This usually works to force Synology Photos to recognize a missing directory's existence.

If photos are still missing, re-index the photos directory: Synology Photos > Account > Settings > (choose between Personal or Shared tabs) > Indexing > click the Re-Index button.

SP will display "indexing..." next to the button. Re-indexing may take a while. I have not found any articles describing a way to watch the progress of the indexing. The only indication that the process has completed is waiting for the "indexing..." message to go away.

DSM 6 and previous (ARCHIVED)[edit]

The following information refers to previous versions of DSM (prior to DSM 7) and are saved for archival purposes

Goal[edit]

Files are saved to a Windows 7 directory.

A scheduled task copies those files to a remote NAS drive.

A task runs on NAS that re-indexes its media nightly (making it available to Photo Station).

How to re-index NAS so the files are available in Photo Station before the nightly indexing.

Log on to NAS with SSH[edit]

See Enable SSH on Synology NAS

Re-index media files[edit]

TODO: Research the differences between command line re-indexing and re-indexing through the DSM Control Panel. I think they do the same thing. If that's the case, using the DSM is easier.

Command line[edit]

SSH to NAS server

usage: 
    Add:    synoindex -a filename
    Delete: synoindex -d filename
    Add folder:    synoindex -A folder
    Delete folder: synoindex -D folder
    Rename/move file/folder:    synoindex -N newfullpath oldfullpath
    Update Photo Images:        synoindex -U photo
    Get from DB:         synoindex -g filename -t [video|music|photo|playlist]

Additionally, this command will re-index a specific media table:[1]

synoindex -R [video|music|photo|playlist|all]

synoindex -h for all command line options.[2]

synoindex can be used to retrieve metadata from indexed files.

Synology DSM[edit]

  • Login to the DSM with an account with administrator priviledges.
  • Control Panel > System > Media Indexing > Media Indexing tab > Re-index button.
  • It will report Indexing media files, which is a slow process.

Checking on the current indexes[edit]

Use the postgreSQL interactive terminal:[3]

DiskStation> sudo psql mediaserver postgres

To display a list of tables:

mediaserver=# \dt
         List of relations
 Schema |   Name    | Type  | Owner 
--------+-----------+-------+-------
 public | directory | table | admin
 public | music     | table | admin
 public | photo     | table | admin
 public | playlist  | table | admin
 public | video     | table | admin
(5 rows)

To check the current number of indexed files:

select count(1) as music_count from music;
select count(1) as photo_count from photo;
select count(1) as video_count from video;

To view the last file indexed:

select * from photo where id = (select max(id) from photo);

To quit type

\q

Notes[edit]

  1. Synology Indexing - Synology Wiki by Clemens Wacha
  2. More on the Synology NAS Automatically Indexing New Files ("codesourcery" blog, 11/29/2012)
    This includes a Python script for watching for file system changes and triggering the synoindex command.
  3. Synology Indexing - Synology Wiki by Clemens Wacha