K
K
krasnovu2014-08-29 23:20:06
linux
krasnovu, 2014-08-29 23:20:06

How to synchronize files in different folder structures and by content?

Children are growing. Photos, videos a lot. There was a need to backup all this from phones, family video cameras. A backup is a set of folders in a mirror, for example, years in the root, months in years, days in months, and the files themselves in days. The name of the file in this format is YYYYMMDD_hhmmss_note.extension.
After switching from Windows to Linux, it was a discovery for me that copying via cp does not copy the date and time of file creation by default (and rsync also has a separate key) - I almost spoiled the old archive during the transfer, I noticed it in time, so I decided to put this information in name, in the future it will be more convenient for grandchildren to look at the date of shooting than at the CAM00353.jpg file, so that it would be more convenient to calculate how old grandparents are here and how old dads are :)
I imagine such an algorithm. I throw off in various ways at various times to the sync folder on the server the directory from the device with the contents. There, once a day, the script on the bash (while I'm experimenting on it) renames all this according to the above format and tries to synchronize (add a new one and delete nothing) with the backup in the mirror. It then deletes the directory in the sync folder.
As I understand it, one of the problems is that everything will be in the root in one directory, and in the other it will lie in subfolders. And another of the problems is that the script will make such 20140829_235735.mp4 from CAM00451.mp4 and put it next to the file /2014/August/29/2014/August/29/20140829_235735_jumping_on_the_couch.mp4, synchronized and manually renamed last time
Hm. While writing, it occurred to me in the first problem to run atomically for each file rsync with a calculated directory. And for the second, is only the file date and size suitable for synchronization?
What other ideas do you have? Maybe there are simpler solutions, including organizational ones?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question