marmaladefly
Posts: 2
Joined: Fri Jul 14, 2017 3:05 pm

security camera data backup

Fri Jul 14, 2017 3:24 pm

I have been using my raspberrypi & camera as a security camera monitoring front drive.
For storage I use a large capacity USB memory stick.
After several days I receive an error as the stick is full and I have to delete files to make room.
So one question is - can i code for this? detect memory is nearly full and then have old files deleted automatically using code so that program doesn't come to a end?
I have a couple of external hard drives that I could use for storage instead.
Rather than connect a hard drive and have that running all day everyday I like the idea of using code to detect when my USB stick storage is full (about four days) then power up the hard drive using remote controlled power sockets; perform USB stick backup to hard drive, then wipe USB stick files, and power down hard drive.
unfortunately by the time I have worked out how to do this my Pi may be obsolete (slow learner)
or is there an easier way?

pageauc
Posts: 223
Joined: Fri Jan 04, 2013 10:52 pm

Re: security camera data backup

Fri Jul 14, 2017 5:21 pm

Could create a simple script to delete files older than a specified number of days. Put this in a crontab to run once a day or as often as needed. Below is just an example so edit find parameters to suit your needs.

Code: Select all

#!/bin/sh
find /home/pi/my_dir -mtime +10 -type f -delete
Usage
  • ./my_dir your directory (replace with your own)
  • -mtime +10 older than 10 days
  • -type f only files
  • -delete
Test before using. Remove - delete parameter to test your find filter before executing the whole command
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp

marmaladefly
Posts: 2
Joined: Fri Jul 14, 2017 3:05 pm

Re: security camera data backup

Fri Jul 14, 2017 6:25 pm

Thank you very much, that should work fine.
I also had a look at one of your utube videos too and motion detection may be of even more use as I wouldn't need to record hours of nothing happening.
Thanks again !

pageauc
Posts: 223
Joined: Fri Jan 04, 2013 10:52 pm

Re: security camera data backup

Sun Jul 16, 2017 8:06 pm

Recently replaced motion detection with motion tracking. Motion detection can trigger false positives from moving bushes or similar. Motion tracking on the other hand requires a minimum size moving object that travels a certain distance. This better ensures motion was real although objects moving straight at the camera might not be triggered by tracking since from the camera's perspective it is not moving sideways or up/down. In the real world most objects move into frame from one side and progress across view for a while. Anyway try out pi-timolo https://github.com/pageauc/pi-timolo. It is mainly geared to headless remote situations and can upload images to a users google drive. I also mention other security camera options so take a look at those links. I like pi-timolo since it gives myself and other users the option of changing the code if they have some background in programming.
Claude ....
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp

Return to “The MagPi”