0

Ok, I could probably spend a lot of time writing a complex set of bash scripts that would accomplish this, but I'm hoping this functionality already exists somewhere.

I have a device in my car which functions as a dashcam. I records video in 3-minute segments. When I get home, it automatically connects to the wifi, and starts an ssh daemon.

I want something which I can call from cron, to ssh in, and rsync the videos to my linux machine. So far this is easy. What I want to do then, is delete files from the dashcam device, but not ALL of them - I want to delete ONLY ones that are older than X days. And I want this somehow tied in with the rsync so it absolutely only deletes them if rsync knows it has copied them.

If rsync had an option like "-remove-source-files-older-than" it would work perfectly.

EDIT: Perhaps there is some tool other than rsync that would be better suited for this task?

0

I have a 2-step approach, that will work:

First, transfer ALL the files as usual with rsync. Then, start another rsync-step with the --remove-source-files option but execute it only on the old video files.

ways to do this (feeding it only the old files):

  • Use ZSH instead of bash, see the answer here: rsync N newest files in a directory. For example, selecting all the files that are older than 24h: ls *(mh+24)
  • use some piping of ls,grep, etc. to filter the files and feed them to rsync, see the other answer in the link
| improve this answer | |
  • Note that the remote system is Android, so I don't have as much flexibility there with what shells to use, etc. I am running rsync on the linux machine side, copying files from the Android device (which runs SSHDroid) – megadave Apr 13 '15 at 17:12
  • And I'd really like it to be tied in with rsync more directly, so that it only deletes files that it has verified it has copied. – megadave Apr 13 '15 at 17:13
  • The tie-in with rsync is already there in my solution. I don't know about Andriod, but you might still be able to hack a solution with ls et. al – Slizzered Apr 13 '15 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.