View Single Post
Old 02-16-2023, 05:54 PM   #11
qkqw
Enthusiast
qkqw is at one with the great books of the world.qkqw is at one with the great books of the world.qkqw is at one with the great books of the world.qkqw is at one with the great books of the world.qkqw is at one with the great books of the world.qkqw is at one with the great books of the world.qkqw is at one with the great books of the world.qkqw is at one with the great books of the world.qkqw is at one with the great books of the world.qkqw is at one with the great books of the world.qkqw is at one with the great books of the world.
 
Posts: 41
Karma: 143000
Join Date: Apr 2022
Device: Kobo Libra 2
After KoboCloud had disappointed me a few times, mostly resulting in me loosing my library (probably due to the bind mount trick), I've decided to give rclone a go. Here's a few pointers if anybody wants to follow along:

Code:
[local]
encoding = Slash,LtGt,DoubleQuote,Colon,Question,Asterisk,Pipe,BackSlash,Ctl,RightSpace,RightPeriod,InvalidUtf8,Dot

[yourRemoteLibrary]
[...]
Kobo uses a VFAT filesystem, which does not like most of the special characters, hence we need to tell rclone to convert them. rclone isn't too smart about this unfortunately, thinking this is a normal Linux setup.

Next, create a script named sync.sh in the same folder:

Code:
#!/bin/sh

RCLONE="/mnt/onboard/.adds/rclone"
REMOTE="yourRemoteLibrary:"
LIBRARY="/mnt/onboard/library"

echo "waiting for internet connection"
r=1;i=0
while [ $r != 0 ]; do
  if [ $i -gt 60 ]; then
    echo "error! no network available"...
    exit 1
  fi
  ping -c 1 -w 3 aws.amazon.com >/dev/null 2>&1
  r=$?
  if [ $r != 0 ]; then sleep 1; fi
  i=$(($i + 1))
done

$RCLONE/rclone \
  --workdir $RCLONE/.cache \
  --ca-cert $RCLONE/cacert.pem \
  --log-file "$RCLONE/rclone.log" \
  --modify-window 3s --ignore-checksum --no-update-modtime \
  --verbose \
  bisync $REMOTE $LIBRARY &&
  qndb -m pfmRescanBooks
A few notes:
  • I've set the workdir to the same folder, in order to not pollute anything else
  • There's a log file called rclone.log which you can use when things go wrong
  • I've had some issues with synchronization and file modification times, as VFAT only seems to support a granularity of up to 2 seconds, hence the modify-window
  • Ignoring the checksum is probably unsafer (only relying on mod-time and file size), but way faster
  • I've decided to not update the file modification times locally, as this led to some interesting problems when rebooting the kobo and having to deal with different timezones

Attention! Before running the script the first time, you need to append a `--resync` flag in order to get bisync working. See the rclone docs: https://rclone.org/bisync/

In case you want to run this script automatically, you can just add a udev rule (e.g. /etc/udev/rules.d/97-rcloud.rules) like this:

Code:
KERNEL=="eth*", ACTION=="add", RUN+="/mnt/onboard/.adds/rclone/sync.sh"
KERNEL=="wlan*", ACTION=="add", RUN+="/mnt/onboard/.adds/rclone/sync.sh"
Thanks @ajkessel who helped me to get started with this.

Ps. You can also just use "rclone sync", if you don't need bidirectional syncing.
qkqw is offline   Reply With Quote