Mark Jones
Mark Jones

Reputation: 21

keeping home directories synchronized on to Linux Boxes

I have two servers, computer A and computer B, both running Linux. I need to write a program or a shell script which will continuously monitor the contents of my home directory on computer A and if anything changes, copy the changes to my home directory on computer B such that both home directories are always the same. (Any changes made to the home directory on computer B and safely be ignored.)

Upvotes: 0

Views: 268

Answers (3)

Darael
Darael

Reputation: 331

Assuming a reasonably recent Linux kernel (one including inotify - it's been present since 2.6.13), you could use inotify-tools as described here to monitor for changes and call rsync on the files to update computer B. That should do what you're asking for, and allow changes on B that don't propagate to A, as well.

You could probably do the same job with incron, which works like cron but based on filesystem events instead of times, but it seems more intended for use with single files.

Upvotes: 2

Andre Holzner
Andre Holzner

Reputation: 18675

Have you considered exporting /home from computer A to computer B via a network file system, e.g. NFS ?

You could also mount the exported filesystem on B in read-only mode so you won't be able to modify the contents of /home from B if that's desired.

Upvotes: 4

t0mm13b
t0mm13b

Reputation: 34592

Use rsync, which will solve your problems. Most distributions would have this already pre-installed.

Upvotes: 0

Related Questions