How to determine which disk contains the latest updates
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to determine which disk contains the latest updates
Hello everyone,
Consider the following scenario: you have two disks that are kept synchronized by some method. Could be RAID, could be LVM snapshots, could be a script. However, something has gone wrong. The disks are out-of-sync and you don't know which disk received which updates. You want to manually re-sync the disks but how do you figure-out which file to copy where?
I'm thinking of saving recursive directory-listings of the entire disks to text-files. Sorting them on last-update and removing all identical entries from the files.
I have a feeling that this is something that can be done with just a few command's but I need some help to get me started.
Chances are pretty high that one disk is the master copy and the other is the backup/secondary .. you should be able to determine the master going by the latest modified times and sync from that one to the other
As I see it, the problem with times is that files that have been backed up will obviuosly have a later timestamp than the originals, but if for some reason the backup has not been made, the original file will have a later time than its out-of date backup. If a backup has failed half-way through, and some files are backed up and others not, then you have a problem.
I don't see a solution other than deciding that backups live in a particular place.
As I wrote in my original post the disks/partitions are synchronized by some method like raid, lvm or a script. That means that file dates are preserved.
Further, the only fact given is that the copies are out-of-sync but no assumptions can be made about one disk/partition being primary or master or current and the other being older. Otherwise this would be a very trivial question. So, a small percentage of files need to be copied, both A -> B and B -> A.
Question: the fastest or shortest bash code that accomplishes this task.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.