Exclude hidden files while using --exclude from bash script

What is the problem you are having with rclone?

I want to exclude hidden files but I am running a bash script which I found here to automate rclone copy / sync whenever file changes.

The script has this line

RCLONE_CMD="rclone -v copy ${RCLONE_SYNC_PATH} ${RCLONE_REMOTE}"

To solve my issue I want to use --exclude '.*{/**,}' which I found here while searching this forum. Thererfore I changed that line like this

RCLONE_CMD="rclone -v copy ${RCLONE_SYNC_PATH} ${RCLONE_REMOTE} --exclude '.*{/**,}'"

But when I run the script, it doesn't exclude the hidden files. I saw the output of that script and it shows the command which it is running as follows:

rclone -v copy /home/saif/vimwiki gdrive:vimwiki --exclude ''\''.*{/**,}'\''

I guess this issue is due to bash expansion but I can't figure out how to solve this.

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

rclone v1.59.1
- os/version: arch 21.3.7 (64 bit)
- os/kernel: 5.15.60-1-MANJARO (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.19
- go/linking: dynamic
- 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)

rclone -v copy /home/saif/vimwiki gdrive:vimwiki --exclude '.*{/**,}'

The above command works while using the command directly in the terminal but it doesn't while using the script. So the rclone is working properly.

The rclone config contents with secrets removed.

[gdrive]
type = drive
client_id = 
client_secret = 
scope = drive
token = 
team_drive = 

A log from the command with the -vv flag

+ rclone -vv copy /home/saif/vimwiki gdrive:vimwiki --exclude ''\''.*{/**,}'\'''
2022/08/28 16:34:19 DEBUG : rclone: Version "v1.59.1" starting with parameters ["rclone" "-vv" "copy" "/home/saif/vimwiki" "gdrive:vimwiki" "--exclude" "'.*{/**,}'"]
2022/08/28 16:34:19 DEBUG : Creating backend with remote "/home/saif/vimwiki"
2022/08/28 16:34:19 DEBUG : Using config file from "/home/saif/.config/rclone/rclone.conf"
2022/08/28 16:34:19 DEBUG : Creating backend with remote "gdrive:vimwiki"

1 Like

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