Rclone and mount with check

Hello,
i'm using rclone and work very well.

i need to mount my remote (Google Drive) to a folder for backup my server.

i don't undestand use of /etc/fstab so i use this scipt on crontab

* * * * * df | /usr/bin/grep /mnt/gdrive > /dev/null 2>&1 || /usr/bin/fusermount -u -z /mnt/gdrive ; nohup /usr/bin/rclone --vfs-cache-mode minimal mount my-remote:/my/remote/path /mnt/gdrive > /dev/null 2>&1

pratically check if /mnt/gdrive is a mount point and if not force dismount and remount it.
work very well and i have a normal consuption of cpu/ram
but when i try top and grep rclone i find ever 2 processes...

one is normal process for mount

other is
/bin/sh -c df | /usr/bin/grep /mnt/gdrive > /dev/null 2>&1 || /usr/bin/fusermount -u -z /mnt/gdrive ; nohup /usr/bin/rclone --vfs-cache-mode minimal mount my-remote:/my/remote/path /mnt/gdrive > /dev/null 2>&1
is normal?

can you help me to improve script?
i need to setup on @reboot (or every minute is ok) and every minute check if /mnt/gdrive is mounted...

thank you

You'd probably be better starting the rclone mount with systemd which will restart it if it dies.

Here is an example: https://www.jamescoyle.net/how-to/3116-rclone-systemd-startup-mount-script

wow, thank you.
i find that very helpful and i edit with
--vfs-cache-mode=minimal
for minor consuption...

last thing.
for check if all ok is correct create a cron like this

0,10,20,30,40,50 * * * * if [ "$(ps ax|grep -v grep|grep rclone|wc -l)" == "0" ];then systemctl restart rclone;fi > /dev/null 2>&1

thank you

You shouldn't need that - systemd will restart rclone because of these lines

Restart=always
RestartSec=10

sorry,
ok

thank you again

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.