Is it possible to BACKUP old versions of uploaded (overwritten) files in the server?

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Thank you very much....now we have a php file which makes the copy of all images..this was a great help for me..

If I am not taking your time much, I want to ask your idea about the unsolved part of the solution as well..
Now I am triggering this php file manually by browser or I can make a cron job for every minute..

But both of them are not good solutions, because
1)If there is no change (new upload according to the dedected motion) in camera image file, it is useless to save a copy of image in every minute
2)And also, in one minute there can be 10 different uploads but I can catch and copy only 1 image in this time period by this way

So is there any other ways possible to run this php triggered by every new uploads, or is it impossible to do that?

I am not sure how your images get put on the server, perhpas your cameras have some notify action ? possibly they can send an email or call a webpage when they save the image... need more info there though.

as for not saving the same image file several times you could use md5_file() to generate a hash of the last image moved, save that somewhere (db or text-file) then check the md5() of the image to make sure it has changed b4 you do your next move?

I see. For entering inotify-tools on linux I don't think so I am brave enough

About md5_file() , I think I understand your point, php file will check this information every time before saving a new file and if it is the same file it will not save..right?
I can guess that it is easy script for you, but it seems a little bit advanced programming for me
I am using iSpy security software for uploading image files, uploads on motion detection, but I couldn't find sending email or caling a web page function paralel with upload..

But I can ask an easier script help from you maybe be the solution of this problem.
If we can modify the current code for saving the image files every hour to a new created folder instead of one stable folder, then it can be possble to manage many saved files.

I mean for every day one parent folder of the day will be created automaticly by php file if it is the first file saving after 12:00 am of previous day. Folders as below
121116
121117
121118
.......

And in each folder, 24 folders will be created one by one by php file when the time comes to save an image if file belongs to a new hour, as
00
01
02
04
....
...
22
23

If its FTP then the most you're going to get is a cycling script that cycles for say 59 seconds before quitting and being restarted by a cron.

If you have total control of the system and can run scripts indefinitely then you could write a service that will just run continually checking for new files and saving them otherwise you're stuck with the 59 seconds and a new cron instance scenario.

Most servers have a php script maximum execution time of either 30 or 60 seconds. Now if you have a 60 second max then you could easily loop a script for 59 seconds (with a sleep between each loop to stop your host shutting you down for CPU hogging). That means that every time the script loops it will check for any files in directory A and copy them into directory B with a new name.

On the 60th second your cron triggers a new version of the script to run and the whole process starts again for another 59 seconds.

If you're unsure of how to set this up, I can do the initial checks of your environment for you (checking max exec time etc) to see if its suitable but if you want the code written by me it would be chargeable.

If that code is that much complex to be chargable I will not try that way. Because this thing which I am trying is a completely amateur effort for me, and the purpose of posting in this forum is for seeking some simple and amateur helps only. Thank you.

In any way, I wonder about is it possible that php script can understand a new file is uploaded while looping? Is it about using the same technique related with md5_file() which "firepages" told in previous posts?

If that code is that much complex to be chargable I will not try that way. Because this thing which I am trying is a completely amateur effort for me, and the purpose of posting in this forum is for seeking some simple and amateur helps only. Thank you.

Don't be put off. It isn't overly complex so it's within your grasp, I was just offering to get you up and running asap for a fee (I've been out of work for 2 years so can't blame me for tryin eh?).

Originally Posted by damlays

In any way, I wonder about is it possible that php script can understand a new file is uploaded while looping? Is it about using the same technique related with md5_file() which "firepages" told in previous posts?

Yes. It would be able to recognise a different file to the last one by checking the MD5 as firepages suggests. An MD5 checksum is basically a 32bit string comprising of letters and numbers which is basically generated through voodoo and creates a digital fingerprint of a file. It's extremely rare for two files to ever share the same MD5 so that is how you could determine if the file is the same or different to the last one moved. Either way, assuming you're moving the file from A=>B then it would no longer be at the source anyway so ths script would just look for new files and move them.