This is an old revision of the document!
This script copies all your .jpg and .avi captures to a mounted NAS. Before it does so, it will check if there is a directory with the date of today. If it doesnt exist it will create one with the subdirectories “Videos” and “Pictures”. After that it copies the files to a non-chaning local directory and then from there to the created directories on your NAS. The script can be executed via crontab.
First mount your NAS.
mount -t cifs //192.168.178.xxx/PATH/ /media/nasdir/Make sure you can access it and that you can see files. If you already have files at “//192.168.178.xxx/PATH/” you can use
ls -al /media/nasdir/. Also create a file with
touch /media/nasdir/testand check if it has been created.
#!/bin/bash DATE=`date +%d_%m_%Y` BASEPATH=/records/ COPYPATH=/records/copy/ NETPATH=/media/nasdir/ if [ ! -d "$NETPATH$DATE" ]; then mkdir $NETPATH$DATE mkdir $NETPATH$DATE/Videos mkdir $NETPATH$DATE/Pictures fi NETPATHAVI=$NETPATH$DATE/Videos NETPATHJPG=$NETPATH$DATE/Pictures mv $BASEPATH*.avi $COPYPATH sleep 10 mv $BASEPATH*.jpg $COPYPATH sleep 10 mv $COPYPATH*.avi $NETPATHAVI sleep 10 mv $COPYPATH*.jpg $NETPATHJPG sleep 10
Discussion