I feel as though I followed all of Animosities steps on his Github page. I have everything working but the cron job to auto upload from my server to my Google Drive each evening.
#!/bin/bash
# RClone Config file
RCLONE_CONFIG=/data/rclone/rclone.conf
export RCLONE_CONFIG
LOCKFILE="/var/lock/`basename $0`"
(
# Wait for lock for 5 seconds
flock -x -w 5 200 || exit 1
# Move older local files to the cloud
/usr/bin/rclone move "/home/russell/data/iTunes/" "gcrypt:iTunes/" --log-file "/opt/rclone/logs/upload.log" --progress -v --drive-chunk-size 64M --delete-empty-src-dirs --fast-list
) 200> ${LOCKFILE}
Nothing turns up in the upload.log.
Syslog has:
Aug 14 23:00:01 [SVR] CRON[25271]: (root) CMD ( /opt/rclone/scripts/upload_cloud)
Aug 14 23:00:01 [SVR] postfix/pickup[13643]: BE32E1A0C24: uid=0 from=
Aug 14 23:00:01 [SVR] postfix/cleanup[25275]: BE32E1A0C24: message-id=<20190814130001.BE32E1A0C24@[SVR]>
Aug 14 23:00:01 [SVR] postfix/qmgr[13644]: BE32E1A0C24: from=<root@[SVR]>, size=663, nrcpt=1 (queue active)
Aug 14 23:00:07 [SVR] postfix/smtp[25277]: BE32E1A0C24: to=<root@[SVR]>, orig_to=, relay=smtp.gmail.com[IP ADDRESS]:587, delay=5.5, delays=0.19/0.11/3.5/1.7, dsn=$
Aug 14 23:00:07 [SVR] postfix/qmgr[13644]: BE32E1A0C24: removed
So it looks like the crontab is working, so I'm guessing the issue is with my upload script?
When I run the command manually, it works fine. /usr/bin/rclone move "/home/russell/data/iTunes/" "gcrypt:iTunes/" --log-file "/opt/rclone/logs/upload.log" --progress -v --drive-chunk-size 64M --delete-empty-src-dirs --fast-list
As a side note, if anyone also knows how to change the email address postfix is sending to that'd be great too
Actually, disregard the postfix comment - I've worked that out
But there is an additional question to the upload script not working. Is there a way to also have it clean up the directories so I'm not left with a heap of [TVShow]/[Season 01] etc directories?
Do you have your config at /data/rclone/rclone.conf? When I first set it up I had to change it to "RCLONE_CONFIG=/home/joe/.config/rclone/rclone.conf".
Sorry! Don't know what I was doing, thought it was a copy of yours from github but must have gotten that from somewhere else. I've updated it and it's now:
#!/usr/bin/bash
# RClone Config file
RCLONE_CONFIG=/data/rclone/rclone.conf
export RCLONE_CONFIG
#exit if running
if [[ "`pidof -x $(basename $0) -o %PPID`" ]]; then exit; fi
# Move older local files to the cloud
/usr/bin/rclone move "/home/russell/data/iTunes/" "gcrypt:iTunes/" --log-file "/opt/rclone/logs/upload.log" -v --drive-chunk-size 64M --delete-empty-src-dirs --fast-list
Thanks. Double checked and the one I'm using is definitely /data/rclone/rclone.conf.
This has gotten me a bit further! The rclone.log from crontab was showing permission denied. So I chown the directory and contents to be root:root now and chmod 777 the upload_cloud file. That's changed it to now display: /bin/sh: 1: /opt/rclone/scripts/upload_cloud: not found
/etc/crontab is:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
18 * * * * root cd / && run-parts --report /etc/cron.hourly
23 02 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
38 02 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
48 02 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
#Cloud Upload
10 18 * * * root /opt/rclone/scripts/upload_cloud >> /tmp/rclone.log 2>&1