Suppress "There was nothing to transfer"?

What is the problem you are having with rclone?

I'm running rclone with cron as a nightly backup of my NAS to s3. The actual behavior of rclone copying and creating backup files works exactly the way I want it to, no problems there.

Now I'd like to get email notifications any time the backup sends new files to or modifies files on s3, but no emails when nothing changes. My cron is setup to send an email only if the command being run generates any output on stdout. Thus, I would like for rclone to generate stdout that lists files transferred or modified on s3, and be completely silent if nothing changes. I almost have it working exactly the way I want, except that when nothing changes rclone prints out There was nothing to transfer, and I would rather have it not print anything. How do I suppress that line of text, but still be able to see the list of transferred or modified files when work happens?

I followed this post to generate the list of synced files.

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

rclone v1.58.1
- os/version: ubuntu 14.04 (64 bit)
- os/kernel: 3.16.0-77-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.17.9
- go/linking: static
- go/tags: none

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

s3

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

s3backup.sh

DEST=aws:mybucket

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DATE=`date +"%FT%H-%M-%S"`
SOURCE_DIR=/data

DEST_DIR="$DEST/last_snapshot"
BACKUP_DIR="--backup-dir=$DEST/archive/$(date +%Y)/$DATE"

CONFIG="--config $DIR/rclone.conf"
OPTIONS="--fast-list --no-update-modtime --links --stats=0 --stats-one-line -v --s3-no-check-bucket --exclude-from $DIR/rclone-exclude.txt $@"  # add --progress when run manually
rclone $CONFIG sync $OPTIONS $SOURCE_DIR $DEST_DIR $BACKUP_DIR

The rclone config contents with secrets removed.

[aws]
type = s3
provider = AWS
access_key_id = <removed>
secret_access_key = <removed>
region = us-east-1
acl = private
server_side_encryption = AES256
storage_class = STANDARD

stdout when I add a file

This works the way I want it to, and it prints what I want it to print!

$ /bin/bash s3backup.sh
2022/05/14 19:09:35 INFO  : Media/Videos/beebooboobop.mp4: Copied (new)

stdout when I deleted some files

This works the way I want it to, and it prints what I want it to print!

$ /bin/bash s3backup.sh
022/05/14 19:45:54 INFO  : Media/Pictures/Photos/Albums/stars/029-DSC07604.tif: Copied (server-side copy)
2022/05/14 19:45:54 INFO  : Media/Pictures/Photos/Albums/stars/029-DSC07604.tif: Deleted
2022/05/14 19:45:54 INFO  : Media/Pictures/Photos/Albums/stars/029-DSC07604.tif: Moved into backup dir
2022/05/14 19:45:55 INFO  : Media/Pictures/Photos/Albums/stars/024-DSC07599.tif: Copied (server-side copy)
2022/05/14 19:45:55 INFO  : Media/Pictures/Photos/Albums/stars/024-DSC07599.tif: Deleted
2022/05/14 19:45:55 INFO  : Media/Pictures/Photos/Albums/stars/024-DSC07599.tif: Moved into backup dir
2022/05/14 19:45:56 INFO  : Media/Pictures/Photos/Albums/stars/033-DSC07628.tif: Copied (server-side copy)
2022/05/14 19:45:56 INFO  : Media/Pictures/Photos/Albums/stars/033-DSC07628.tif: Deleted
2022/05/14 19:45:56 INFO  : Media/Pictures/Photos/Albums/stars/033-DSC07628.tif: Moved into backup dir
2022/05/14 19:45:57 INFO  : Media/Pictures/Photos/Albums/stars/036-DSC07632.tif: Copied (server-side copy)
2022/05/14 19:45:57 INFO  : Media/Pictures/Photos/Albums/stars/036-DSC07632.tif: Deleted
2022/05/14 19:45:57 INFO  : Media/Pictures/Photos/Albums/stars/036-DSC07632.tif: Moved into backup dir

stdout when I don't change anything

This is where the problem is - while it correctly does nothing, it prints this line and I would rather it just return without printing anything!

$ /bin/bash s3backup.sh
2022/05/14 20:23:53 INFO  : There was nothing to transfer

Thanks in advance!

i have a python script that runs rclone.

after each run of rclone, the script scans the debug log, looks for certain text, missing text etc..
based on that, the script sends me a summary email.

another option could be exit code
" 9 - Operation successful, but no files transferred"

I modified my script to write to log (instead of stdout), check the exit code, and send mail if it is not 9 (per your suggestion). I also disabled cron from sending mail. The script is sending me mail every time it runs because it is actually returning 0 even when the only thing the log says is There was nothing to transfer. According to the list of exit codes that should be 9, so why is it returning 0?

DEST=aws:mybucket

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DATE=`date +"%FT%H-%M-%S"`
SOURCE_DIR=/data

DEST_DIR="$DEST/last_snapshot"
BACKUP_DIR="--backup-dir=$DEST/archive/$(date +%Y)/$DATE"

CONFIG="--config $DIR/rclone.conf"
LOG_OPTIONS="--log-file=/logs/rclone/$DATE.log"
OPTIONS="--fast-list --no-update-modtime --links --stats=0 --stats-one-line -v --s3-no-check-bucket --exclude-from $DIR/rclone-exclude.txt $@"  # add --progress when run manually
rclone $CONFIG sync $OPTIONS $SOURCE_DIR $DEST_DIR $BACKUP_DIR $LOG_OPTIONS
if [ $? -ne 9 ]; then
   mail -s "Backup Complete $DATE" myemail@domain.com < /logs/rclone/$DATE.log
fi

need to use --error-on-no-transfer

That did the trick. Thank you for your help!

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