I succeeded in transferring all files from a folder via ftp from a remote server to a raspberry, but I would like to transfer only new ones. Below is the working script i have.
#!/bin/bash -vx ftp -in IP_SERVER<<END_SCRIPT quote USER rem_user quote PASS rem_pass bin prompt:off cd /path_to_server_files lcd /path_to_local_files mget *.mp3 bye END_SCRIPT
I have a company that provides background music to other companies. My method was leaving a computer in each one playing 24/7 or with other specific cron jobs, depending on the client. And the raspberry is a great way to do that instead a computer. The method i have right know that is working is a cron job per folder. Each folder has a type of music. So i will be putting different music from time to time in the server and the cron job will transfer those files once a week. It is set to transfer every mp3 file in that folder to the RPi. The thing is, it will transfer all the files there including the ones that were already there. If i put there, for example, 150 music files, it will take a long time transferring those, not to mention if it is done with all the folders since the RPi ARM is not that powerful. The solution would be not overwriting the files already there, just the new ones. Then after some time another cron job will delete all the files that have more than * days old.
I searched but it seems ftp doesn't have an option like this yet. So I found the wget command which allows to transfer without overwriting but i couldn't make it transfer multiple files. I have been trying to convert the script above with the wget command without success. Can someone with experience in this matter help out? It could be a problem with http also. Thanks in advance.
I have tried with wget command:
* * * * * wget -r -l1 -N -A.mp3 'ftp://serverUser:Password@serverIP/path_to_server_files' /var/www/rd/musica/teste/ftp11.log 2>&1
ftp://serverUser:Password@serverIP/path_to_server_files: Bad Port Number /var/www/rd/musica/teste: Scheme Missing
This is my attempt with rsync:
The rsyncd.conf: (I am not sure if all credentials are right, so I'ĺl put every file in here so it can be corrected.)
lock file = /var/run/rsync.lock lock file = /var/log/rsyncd.log pid file = /var/run/rsync.pid [documents] path = /var/www/rd/musica/teste comment = The documents folder of localusername uid = localusername gid = localusername read only = no list = yes auth users = serverusername secrets file =/etc/rsync.secrets hosts allow = serverIP/255.255.255.0
command to run rsync:
rsync -rtv serverusername@serverIP::documents/path_to_server_files/*.mp3 /path_to_local_destination_folder
It returns these errors:
rsync: failed to connect to serverIP (serverIP): Connection refused (111) rsync error: error in socket IO (code 10) at clientserver.c(122) [Receiver=3.0.9]