Using systemd service ERROR

What is the problem you are having with rclone?

I'm trying to run a .sh file with systemd service, but it does not work.
When I run the command in the terminal it work properly, and when I run .sh file too.

.sh content:

#!/bin/bash
/usr/bin/rclone sync -v --fast-list --transfers 30 /home/user/Documents google-drive:laptop

The problem starts when I try to run the systemd service:

.service file content:

[Unit]
Description=Run the Google Drive Backups

[Service]
Type=simple
ExecStart=/usr/local/bin/google-drive_rclone-sync.sh --config /home/user/.config/rclone/rclone.conf

When I run the service this error occurs:

google-drive_backups.service - Run the Google Drive Backups
     Loaded: loaded (/etc/systemd/system/google-drive_backups.service; static)
     Active: failed (Result: exit-code) since Sat 2022-08-20 16:31:47 -03; 8s ago
    Process: 32855 ExecStart=/usr/local/bin/google-drive_rclone-sync.sh --config /home/user/.config/rclone/rclone.conf (code=exited, status=1/FAILURE)
   Main PID: 32855 (code=exited, status=1/FAILURE)
        CPU: 46ms

ago 20 16:31:47 fedora systemd[1]: Started google-drive_backups.service - Run the Google Drive Backups.
ago 20 16:31:47 fedora google-drive_rclone-sync.sh[32856]: Failed to create file system for "google-drive:laptop": didn't find section in config file
ago 20 16:31:47 fedora systemd[1]: google-drive_backups.service: Main process exited, code=exited, status=1/FAILURE
ago 20 16:31:47 fedora systemd[1]: google-drive_backups.service: Failed with result 'exit-code'.

I've tried indicating config file, and tried not indicanting too.
This error does not occur when I paste the liteal command in .service, just when I try to use a .sh file in it.

Run the command 'rclone version' and share the full output of the command.

rclone v1.59.1

  • os/version: fedora 36 (64 bit)
  • os/kernel: 5.18.18-200.fc36.x86_64 (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.18.5
  • go/linking: static
  • go/tags: none

Which cloud storage system are you using? (eg Google Drive)

Google Drive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

I've tried two:

rclone sync -v --fast-list --transfers 30 /home/user/Documents google-drive:laptop
rclone --vfs-cache-mode writes mount google-drive: /home/user/googledrive

The rclone config contents with secrets removed.

[OneDrive]
type = onedrive
token = {"access_token":"REDACTED","token_type":"Bearer","refresh_token":"REDACTED","expiry":"REDACTED"}
drive_id = REDACTED
drive_type = personal

[google-drive]
type = drive
scope = drive.file
token = {"access_token":"REDACTED","token_type":"Bearer","refresh_token":"REDACTED","expiry":"REDACTED"}
team_drive = 

A log from the command with the -vv flag

Does not apply

You'd want to put that in the sh file not the place you got it or put the environment variable in the service file.

I do this in my [Service] section

Environment=RCLONE_CONFIG=/opt/rclone/rclone.conf

OMG, you nailed it.

Thank you very much.
Spent hours searching this, and it was so simple.
:smile:

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