3

I have several cameras that upload data to a Samba server running under Debian. The video files are initially uploaded to a larger external drive, but I would also like to maintain a copy of the latest files on a smaller internal drive. I have installed lsyncd and it works until it runs out of space on the smaller drive. I am looking for a solution that would automatically delete the oldest files in order to make space for the newest files.

Is there an existing piece of software that can do this, or can lsycnd be configured to handle this situation? The OS is Debian 8.5.

-1

You can use rsync to synchronize the two directories.

A simple command could be

rsync -avz src/* dest

This will sync the contents of the src directory to the dest directory.

  • I am familiar with rsync, however the problem I am trying to solve is basically copying the most recent 6 GB of files from a 64 GB drive to a drive with 6 GB of free space. – Adam Aug 18 '17 at 16:08
  • 1
    This doesn't do anything remotely like what the question asks: copy the most recent files and delete the oldest files. – Gilles Aug 18 '17 at 21:58
-1

This will copy last 24 hours files only.

find /path/to/src -type f -mmin -$((60*24)) -exec rsync '{}' /to/dest \;

To delete the files older than 24 hours use,

find /path/to/src -type f -mtime +$((60*24))' -delete
  • 1
    Yes, but the question asked how to delete the oldest files to make room. – Gilles Aug 18 '17 at 21:58
  • @Gilles, sorry. I didn't read the question carefully, I have updated my answer – αғsнιη Apr 9 '18 at 11:50

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.