Skip to content

Instantly share code, notes, and snippets.

@joshkerr
Created January 24, 2020 20:23
Show Gist options
  • Save joshkerr/19b8546af41441e2f8266e325f1e5a4a to your computer and use it in GitHub Desktop.
Save joshkerr/19b8546af41441e2f8266e325f1e5a4a to your computer and use it in GitHub Desktop.
rclone to Google Drive using Team drives and switching between them to prevent API limitations.
#!/bin/sh
lastsync=$(tail -1 lastsync.txt | head -1)
if [ $lastsync = "Team" ]; then
teamnumber=""
echo "Team1" > lastsync.txt
elif [ $lastsync = "Team1" ]; then
teamnumber="1"
echo "Team2" > lastsync.txt
elif [ $lastsync = "Team2" ]; then
teamnumber="2"
echo "Team3" > lastsync.txt
elif [ $lastsync = "Team3" ]; then
teamnumber="3"
echo "Team" > lastsync.txt
fi
echo "Using Team Account $lastsync to save to Drive"
driveToUse=GDrive-Team$teamnumber
SRCpath=/home/hd3/adskii/ToMove
echo $driveToUse
seriesSRC="$SRCpath/Unorganised Series"
filmsSRC="$SRCpath/Unorganised Films"
musicSRC="$SRCpath/Unorganised Music"
appsSRC="$SRCpath/Downloaded Apps"
booksSRC="$SRCpath/E-Books"
dlvideoSRC="$SRCpath/Videos-To-Move"
seriesDST="$driveToUse:Unorganised Series"
filmsDST="$driveToUse:Unorganised Films"
musicDST="$driveToUse:Unorganised Music"
appsDST="$driveToUse:Downloaded Apps"
booksDST="$driveToUse:Unorganised Books"
dlvideoDST="$driveToUse:Plex Cloud Videos"
/usr/local/bin/rclone --exclude /hold --retries 50 move -v "$seriesSRC" "$seriesDST"
/usr/local/bin/rclone --exclude /hold --retries 50 move -v "$filmsSRC" "$filmsSRC"
/usr/local/bin/rclone --exclude /hold --retries 50 move -v "$musicSRC" "$musicDST"
/usr/local/bin/rclone --exclude /hold --retries 50 move -v "$appsSRC" "$appsDST"
/usr/local/bin/rclone --exclude /hold --retries 50 move -v "$booksSRC" "$booksDST"
count=`ls /home/hd3/adskii/ToMove/Videos-To-Move/*.part | wc -l`
echo '.Part files existing ' $count
if [ $count -lt 1 ]
then
echo 'Video Sync Running'
/usr/local/bin/rclone --exclude /hold --retries 50 move -v "$dlvideoSRC" "$dlvideoDST"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment