#!/bin/bash

SRC=$1
DST=$2
AGE=$3
#BW=$4
TAIL_IP=$(hostname)
RCLONE_CONF_FILE=/opt/rclone/rclone.conf

#[ -z "$SRC" ] && SRC=dbc_media:movies
#[ -z "$DST" ] && DST=/mnt/unionfs/movies
#[ -z "$AGE" ] && AGE=1d
#[ -z "$BW" ] && BW=2M

RCLONE_SRC=$SRC
RCLONE_DST=$DST
#RCLONE_EXCLUDE1=".zzz_*"
#RCLONE_EXCLUDE2="*_move*"
#RCLONE_MOVE_MIN_AGE=$AGE
RCLONE_HOST="$TAIL_IP":44444
RCLONE_CRED=rcd
#RCLONE_TRANSFERS=8
RCLONE_LOG_FILE=/var/log/rclone/rclone_move_rc.log
#RCLONE_LOG_LEVEL=NOTICE

[[ ! -f "$RCLONE_LOG_FILE" ]] && touch "$RCLONE_LOG_FILE" && sudo chmod 777 "$RCLONE_LOG_FILE"

rclone rc sync/move srcFs="$SRC" dstFs="$DST" \
--config "$RCLONE_CONF_FILE" \
--exclude "/_*" \
--rc-addr="$RCLONE_HOST" \
--rc-user=$RCLONE_CRED \
--rc-pass=$RCLONE_CRED \
_async=true \
--fast-list \
--log-file $RCLONE_LOG_FILE