We have an IP PBX that is running Asterisk and is set by the manufacturer to delete call recordings after a certain time period. I am backing these up to an Ubuntu server using rsync so that we are able to store them indefinitely.
The issue that I have is that all of the recordings are all placed into a single directory. Conveniently the files are named in the same structure:
year.month.day.hour.min.sec-callref-extension-callerid.wav
What I would like to do is set up a directory structure that would be Year/Month/Day (with the month being correctly ordered), then move each of the files into the corresponding order.
Personal note: I am confident at working with Ubuntu at the command line but don't have experience of running or automating scripts so advice is greatly welcomed. (Happy to learn!) Thanks in advance.
The script that was supplied earlier is working great. I have come upto a further slight issue.
I am using a crontab to rsync IPPBX to Ubuntu Server, then another to file these recordings using the script below. Each evening the rsync is re-downloading all the recordings as it thinks that the destination folder is empty.
I have two questions: Can the rsync be incorporated into the script below so that one a single file is used? Can the script understand what has already been downloaded so that it is only downloading new files?