Printable Version of Topic

Click here to view this topic in its original format

Linuxhelp _ Programming in Linux _ Script to copy files, Rsync?

Posted by: Ruffe42 Apr 28 2014, 04:05 PM


I need some help to make a script to copy files from a local folder to a network drive.
First of all I want to tell you this is my first time in linux environment, so be kind and clear. tongue.gif

My setup: Raspberry Pi with Raspbian wheezy, with a local connected USB-drive and a network drive. I have mounted both drives so they are available from the pi.

/home/pi DOWNLOAD > completed (local USB-drive)
MOVIES > HD (Network Drive part.1)
TV > SERIES > X (Network Drive part.2)
Y (Network Drive part.2)
Z (Network Drive part.2)

I want a script that copy all specific files (.avi etc) from /home/pi/DOWNLOAD/completed which dosen't already exist on the destination and put those in the predetermined folder.

etc. /home/pi/DOWNLOAD/completed/xxxxxYxx.avi goes to /home/pi/TV/SERIES/Y
/home/pi/DOWNLOAD/completed/xxxxxXxx.avi goes to /home/pi/TV/SERIES/X
/home/pi/DOWNLOAD/completed/xxxxxZxx.avi goes to /home/pi/TV/SERIES/Z
/home/pi/DOWNLOAD/completed/xxxxxxxx.avi goes to /home/pi/MOVIES/HD

I've struggled with rsync for a few days now and I think I got a good structure but somehow nothing happens when I run the .sh-script and when I try to run the rsync command manually it just say it is a (dry-run) even though I don't have the parameter -n in the command.

here is my "script" ^^'


#the header for log-file
echo '-----------------------------------------------------------------------------' >> $LOG_FILE
date >> $LOG_FILE

#rsync commands
rsync -av --include='*/' --include='*X*.avi' --exclude '*' -prune-emty-dirs /home/pi/DOWNLOAD/completed /home/pi/TV/SERIES/X &>> $LOG_FILE
rsync -av --include='*/' --include='*Y*.avi' --exclude '*' -prune-emty-dirs /home/pi/DOWNLOAD/completed /home/pi/TV/SERIES/Y &>> $LOG_FILE
rsync -av --include='*/' --include='*Z*.avi' --exclude '*' -prune-emty-dirs /home/pi/DOWNLOAD/completed /home/pi/TV/SERIES/Z &>> $LOG_FILE
rsync -av --include='*/' --include='*.avi' --exclude '*' --exclude='*X*.avi' --exclude='*Y*.avi' --exclude='*Z*.avi' -prune-emty-dirs /home/pi/DOWNLOAD/completed /home/pi/MOVIES/HD &>> $LOG_FILE

I would really appreciate some help, maybe there is another tool I can use? I'm stuck and really desperate..

Please help me!
br J

Powered by Invision Power Board (
© Invision Power Services (