Syncthing 2.0 on QNAP NAS

Hello,

I have a QNAP NAS and I installed syncthing from the package manager (myQNAP repository).

The actual version is 1.3.0.

Today I noticed in the syncthing administrative interface the button to upgrade it to the latest 2.0.

I tried but something went wrong and the application couldn’t restart well. I think the upgrade procedure is not compatible with the installed package and the way qnap installed it.

Any idea or advice?

Thanks

Max

Hello Max:

I’ve just been looking at exactly the same thing today!

The problem lies in the launch script - syncthing.sh - which needs editing to update it for the new double-dash arguments. Once this is done, you should be good.

To do this, you’ll need to SSH into the Qnap and find the syncthing.sh file - for me it was in /share/ZFS531_DATA/.qpkg/syncthing/syncthing.sh - but I don’t know if the early parts of this file path are different for different installations.

Hope that helps…

What exactly needs editing?

Thanks!

Hi,

thanks for your reply but what exactly should be edited?

You mean

/usr/bin/sudo -u $USER $QPKG_ROOT/syncthing -gui-address=0.0.0.0:8384 -home=$HOME -logfile=$HOME/synthing.log &

that should be

/usr/bin/sudo -u $USER $QPKG_ROOT/syncthing –gui-address=0.0.0.0:8384 –home=$HOME –logfile=$HOME/synthing.log &

is that?

1 Like

Your formatting has been messed up by the forum software (which merged double -- dashes into en dashes), but basically you need to change all leading single - dashes to double -- dashes, e.g. --home instead of -home, etc.

I edited the script and tried the upgrade again but synthing.log shows only the server is shutting down but not restarting

Ok i stopped the application from the App Center and started again and it works. Thank you

Not sure if I have exactly the same script (same name but different capitalisation). Mine had the same command (and fix), but also had an earlier line syncthing -upgrade which I changed to syncthing upgrade.

I noticed there is also a syncthing -upgradeand I didn’t change it. I don’t know if it’s correct or the dash should be removed or it needs a double dash. I just know that the upgrade (from the web dashboard) worked but the server didn’t restart as expected. The log showed syncthing shutdown but not a restart. So i stopped the application from App Center (although it was already stopped) and then I restarted it.

Yes, I had the same - running on my 15 year old ancient QNAP TS-559 Pro II. I looked up where syncthing.sh in /etc/init.d/ was referring to. For me it was /share/MD0_DATA/.qpkg/syncthing and on line 105 I changed

/sbin/daemon_mgr syncthing start “$DAEMON -home ${QPKG_DIR}/config $LOGSY &” into /sbin/daemon_mgr syncthing start “$DAEMON --home ${QPKG_DIR}/config $LOGSY &”

1 Like

I had the same Problem.

QNAP TS-431P3

I solved it with next code.

#!/bin/sh

CONF=/etc/config/qpkg.confQPKG_NAME=“SyncThing”QPKG_ROOT=$(/sbin/getcfg $QPKG_NAME Install_Path -f ${CONF})export QNAP_QPKG=$QPKG_NAME

export SHELL=/bin/shexport LC_ALL=en_US.UTF-8export LANG=en_US.UTF-8export LC_CTYPE=en_US.UTF-8export USER=admin

export HOSTNAMEexport QPKG_ROOT QPKG_NAMEexport PATH=$QPKG_ROOT/bin:$PATHexport HOME=$QPKG_ROOT

export USER=syncthingexport PIDF=/var/run/syncthing.pidexport LOGFILE=$HOME/syncthing.log

case “$1” instart)ENABLED=$(/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF)if [ “$ENABLED” != “TRUE” ]; thenecho “$QPKG_NAME is disabled.”exit 1fi

/bin/ln -sf $QPKG_ROOT /opt/$QPKG_NAME

if getent passwd $USER > /dev/null 2>&1; then
    echo "User $USER exists"
else
    adduser $USER -g "Linux User,,," -h /tmp -D -S -G everyone
    touch $QPKG_ROOT/test_user
    chown $USER $QPKG_ROOT
fi

cd /share
$QPKG_ROOT/syncthing upgrade

echo "Starting Syncthing..." >> $LOGFILE
/usr/bin/sudo -u $USER $QPKG_ROOT/syncthing \
  --gui-address 0.0.0.0:8384 \
  --home="$HOME" \
  --logfile="$LOGFILE" >> $LOGFILE 2>&1 &

echo $! > $PIDF
sleep 15
;;

stop)if [ -f $PIDF ]; thenkill -9 $(cat $PIDF) > /dev/null 2>&1 || truerm -f $PIDFfikillall -9 syncthing > /dev/null 2>&1 || truerm -rf /opt/$QPKG_NAME

if [ -f $QPKG_ROOT/test_user ]; then
    rm -f $QPKG_ROOT/test_user
    deluser $USER > /dev/null 2>&1 || true
fi
;;

restart)$0 stop$0 start;;

*)echo “Usage: $0 {start|stop|restart}”exit 1;;esac

exit 0

Wanted to share my experience with upgrading my environment. My 3 QNAP units are dual-tier, with SATA HDDs for bulk storage and critical files and high-load apps on SSD. The Syncthing QPKG is hosted on SSD, along with its back-end DB. In my case (QTS 5.2.6, SSD array was the second to be created), the path was /share/CE_CACHEDEV2_DATA/.qpkg/SyncThing. My installed Syncthing version before I started the upgrade was 1.30.0, and the web UI offered to upgrade to 2.0.2.

  1. Refresh your off-box backups (I use an OWC RAID enclosure with SATA SSDs that I unplug and put away when done)
  2. Enable SSH connectivity to each QNAP if disabled
  3. Pause or minimize all other storage activities until the upgrade completes to reduce resource thrashing
  4. Start the Syncthing upgrade from its web UI, watch Resource Monitor in the QNAP web UI to see when all Syncthing processes stop
  5. Stop the Syncthing app in QNAP App Center
  6. SSH to the unit and edit /share/<RAID ID where Syncthing QPKG is hosted>/.qpkg/SyncThing/SyncThing.sh
  7. Scroll down to lines 36 and 38 and change all CLI flags to use double-dashes. (Pasted version below.) Save the file.
  8. Start Syncthing app in QNAP App Center. Don’t touch anything except Performance Monitor and try to stop/minimize all other storage activities. When the upgrade completes, you’ll see your disk utilization drop down to normal levels, and the Syncthing web UI will come up. The RAID array where the Syncthing QPKG is installed will get hammered the hardest - I saw spikes of up to 145 MB/s.

Lines to change in SyncThing.sh - this is the final state

$QPKG_ROOT/syncthing --upgrade ;
$QPKG_ROOT/syncthing --gui-address=0.0.0.0:8384 --home=$HOME --logfile=$HOME/synthing.log &echo $! > $PIDF

For an idea of how long my first upgrade took:

  • QNAP TS-464 with Celeron N5095 and 4GB RAM
  • QM2 expansion card with 2x Crucial P3 Plus 2TB SSDs
  • Encrypted RAID1
  • Syncthing managing 5 shares with combined ~12TB across 720K files
  • First start after modifying SyncThing.sh took ~45 minutes
  • Rescanning all shared folders and syncing with the remote arrays took ~15 minutes
3 Likes

Looking at the snippets shared in this topic, it seems I’m lonely with my QPKG installation, which seems completely different. I would say, that I’m running Syncthing from that package over a decade or so (from v0.11 or v0.10).

I started with Syncthing from a QPKG installation but I noticed the application proposed an upgrade to v2.0 while the QPKG was limited to the v1.3. Maybe it takes time before the package’s update.

For example, on my laptop syncthing didn’t propose any update to the v2.0.

Just to be sure, is it really running v1.3.0 (which is very, very old) or v1.30.0 (which is the last version before v2.0.0)?

This depends on how you’ve installed Syncthing, whether checking for upgrades is disabled, etc.

Yes, sorry, it was 1.30.

Regarding the Syncthing on laptop I don’t remember how I installed it but automatic upgrade is disabled by administrator or mantainer

I just found out this: Auto upgrades are not enabled in builds delivered via APT. I think I installed it from the repository

Yeah, assuming you use the official APT packages, you need to manually change the channel in order to upgrade to Syncthing v2 (see https://apt.syncthing.net).

FWIW I used the QPKG from here - Release v1.23.0-alpha1 · bmachek/syncthing-qnap · GitHub - and it prompted me for the v2 upgrade. At that point I then had to edit the syncthing.sh file to add double-dashes, as already noted.

There is now “official” release of Syncthing 2.0.2 at MyQNAP.org

I haven’t tried it yet.

1 Like