Tar files older than x days
This will do the trick:
# find /path/to/files -type f -mtime +50 | xargs tar cvf archive.tar
You can stick it in crontab and have it run daily.
Edit: Remember that this will not remove the files from the system, only add them to the archive.
To append to the archive, use the r
option rather than c
:
find dirname -type f -mtime +50 | xargs tar rvf archive.tar
To only append the files if they are newer than the copy that's already in the archive:
find dirname -type f -mtime +50 | xargs tar uvf archive.tar