Hy guys. Sorry if it's a duplicate question. I can't find this exact issue using the search.
Let me explain my scenario:
I use rclone to backup my files and databases
I've created a systemd service to mount my Google Drive to /mnt/gdrive path, and it's ok. It works.
So I have a cron job, that executes a script. In that part I have a problem:
My script runs well when I execute it.
My script runs well when cronjob executes it while I'm connected BUT
My script fails when cronjob executes it while I'm NOT connected.
My log files says it cannot find my mounted path (mnt/gdrive).
What I'm missing? Does systemd service should be running when nobody is connected?
What is the problem you are having with rclone?
When bash script run on sheduled cron task when I'm connected Everything works Well. But when cron executes it when no one is connected, the mounted path is not accesible.
What is your rclone version (output from rclone version)
rclone v1.45
os/arch: linux/arm
go version: go1.11.6
Which OS you are using and how many bits (eg Windows 7, 64 bit)
Raspbian, 32bit
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)
This is part of my script, but as it's a mounted directory, I'm not using rclone commands, is a tar command putting the compressed file directly to mounted folder.
tar -czvf $backup_path/$actual_date"_"$SITE.tar.gz --absolute-names /var/www/$SITE/*
It's not a rclone command, so the log does not exists.
Systemd service
[Service]
Type=notify
#Set up environment
Environment=REMOTE_NAME="%i"
Environment=REMOTE_PATH="/"
Environment=MOUNT_DIR="/mnt/%i"
Environment=RCLONE_CONF="%h/.config/rclone/rclone.conf"
Environment=RCLONE_TEMP_DIR="/tmp/rclone/%u/%i"
#Default arguments for rclone mount. Can be overridden in the environment file
Environment=RCLONE_MOUNT_ATTR_TIMEOUT="1s"
#TODO: figure out default for the following parameter
Environment=RCLONE_MOUNT_DAEMON_TIMEOUT="UNKNOWN_DEFULT"
Environment=RCLONE_MOUNT_DIR_CACHE_TIME="5m0s"
Environment=RCLONE_MOUNT_DIR_PERMS="0777"
Environment=RCLONE_MOUNT_FILE_PERMS="0666"
Environment=RCLONE_MOUNT_GID="%G"
Environment=RCLONE_MOUNT_MAX_READ_AHEAD="128k"
Environment=RCLONE_MOUNT_POLL_INTERVAL="1m0s"
Environment=RCLONE_MOUNT_UID="%U"
Environment=RCLONE_MOUNT_UMASK="022"
Environment=RCLONE_MOUNT_VFS_CACHE_MAX_AGE="1h0m0s"
Environment=RCLONE_MOUNT_VFS_CACHE_MAX_SIZE="off"
Environment=RCLONE_MOUNT_VFS_CACHE_MODE="off"
Environment=RCLONE_MOUNT_VFS_CACHE_POLL_INTERVAL="1m0s"
Environment=RCLONE_MOUNT_VFS_READ_CHUNK_SIZE="128M"
Environment=RCLONE_MOUNT_VFS_READ_CHUNK_SIZE_LIMIT="off"
#TODO: figure out default for the following parameter
Environment=RCLONE_MOUNT_VOLNAME="UNKNOWN_DEFULT"
#Overwrite default environment settings with settings from the file if present
EnvironmentFile=-%h/.config/%i.env
#Check that rclone is installed
ExecStartPre=/usr/bin/test -x /usr/bin/rclone
#Check the mount directory
ExecStartPre=/usr/bin/test -d "${MOUNT_DIR}"
ExecStartPre=/usr/bin/test -w "${MOUNT_DIR}"
#TODO: Add test for MOUNT_DIR being empty
#Check the rclone configuration file
ExecStartPre=/usr/bin/test -f "${RCLONE_CONF}"
ExecStartPre=/usr/bin/test -r "${RCLONE_CONF}"
#TODO: add test that the remote is configured for the rclone configuration
#Mount rclone fs
ExecStart=/usr/bin/rclone mount \
--config="${RCLONE_CONF}" \
#See additional items for access control below for information about the following 2 flags
--allow-other \
# --default-permissions \
--cache-tmp-upload-path="${RCLONE_TEMP_DIR}/upload" \
--cache-chunk-path="${RCLONE_TEMP_DIR}/chunks" \
--cache-workers=8 \
--cache-writes \
--cache-dir="${RCLONE_TEMP_DIR}/vfs" \
--cache-db-path="${RCLONE_TEMP_DIR}/db" \
--no-modtime \
--drive-use-trash \
--stats=0 \
--checkers=16 \
--bwlimit=40M \
--dir-cache-time=60m \
--cache-info-age=60m \
--attr-timeout="${RCLONE_MOUNT_ATTR_TIMEOUT}" \
#TODO: Include this once a proper default value is determined
# --daemon-timeout="${RCLONE_MOUNT_DAEMON_TIMEOUT}" \
# --dir-cache-time="${RCLONE_MOUNT_DIR_CACHE_TIME}" \
# --dir-perms="${RCLONE_MOUNT_DIR_PERMS}" \
# --file-perms="${RCLONE_MOUNT_FILE_PERMS}" \
# --gid="${RCLONE_MOUNT_GID}" \
# --max-read-ahead="${RCLONE_MOUNT_MAX_READ_AHEAD}" \
# --poll-interval="${RCLONE_MOUNT_POLL_INTERVAL}" \
# --uid="${RCLONE_MOUNT_UID}" \
# --umask="${RCLONE_MOUNT_UMASK}" \
# --vfs-cache-max-age="${RCLONE_MOUNT_VFS_CACHE_MAX_AGE}" \
# --vfs-cache-max-size="${RCLONE_MOUNT_VFS_CACHE_MAX_SIZE}" \
# --vfs-cache-mode="${RCLONE_MOUNT_VFS_CACHE_MODE}" \
# --vfs-cache-poll-interval="${RCLONE_MOUNT_VFS_CACHE_POLL_INTERVAL}" \
# --vfs-read-chunk-size="${RCLONE_MOUNT_VFS_READ_CHUNK_SIZE}" \
# --vfs-read-chunk-size-limit="${RCLONE_MOUNT_VFS_READ_CHUNK_SIZE_LIMIT}" \
#TODO: Include this once a proper default value is determined
# --volname="${RCLONE_MOUNT_VOLNAME}"
"${REMOTE_NAME}:${REMOTE_PATH}" "${MOUNT_DIR}"
#Unmount rclone fs
ExecStop=/bin/fusermount -u "${MOUNT_DIR}"
#Restsart info
Restart=on-success
RestartSec=10
[Install]
WantedBy=default.target
I'd suggest you cut out the middle man and just send it directly if possible rather than relying on the mount to send the data. But this is really just an aside.
I modified my script, but apparently I need flag to use with rclone rcat
Usage:
rclone rcat remote:path [flags]
Flags:
-h, --help help for rcat
Use "rclone [command] --help" for more information about a command.
Use "rclone help flags" for to see the global flags.
Use "rclone help backends" for a list of supported services.
Command rcat needs 1 arguments maximum: you provided 2 non flag arguments: ["gdrive:" "/mnt/gdrive/www/2020-06-19_11-53-47_batalhaorganizada.com.br.tar.gz"]
Command rcat needs 1 arguments maximum: you provided 2 non flag arguments: ["gdrive:" "/mnt/gdrive/www/2020-06-19_11-53-47_batalhaorganizada.com.br.tar.gz"
You have a space....
Shoudl be like this:
"gdrive:/mnt/gdrive/www/2020-06-19_11-53-47_batalhaorganizada.com.br.tar.gz"
not this:
gdrive: /mnt/gdrive/www/2020-06-19_11-53-47_batalhaorganizada.com.br.tar.gz
It simple looks like you're getting duplicates because its replacing existing files. See these line?
2020/06/19 15:30:11 DEBUG : 2020-06-19_15-24-03_default.tar.gz: MD5 = dfd7734cb45aa3fbfe28ceb114d2825f OK
2020/06/19 15:30:11 INFO : 2020-06-19_15-24-03_default.tar.gz: Copied (new)
That copied it new. Which is what I expect.
This is replacing an existing file. That shouldn't exist if it hasn't been created yet.
2020/06/19 15:37:08 DEBUG : 2020-06-19_15-24-03_indgoo.com.tar.gz: Sending chunk 0 length 1243565
2020/06/19 15:37:10 DEBUG : 2020-06-19_15-24-03_indgoo.com.tar.gz: Size and modification time the same (differ by -111.185µs, within tolerance 1ms)
Are you running this multiple times on top of itself? Google drive allows duplicates and it looks like that's what you're getting.