-1

Put it simply: I have a folder full of files and subfolders with more files. I would like to have a mirror of that folder in a remote server so anytime a file is modified on my machine it gets automatically sent over to the remote machine via scp or whatever. Note that this is a one-way synchronization only, in other words, if the file gets modified in the remote server I don't need to send it back to my local machine.

Basically I want to work with my files locally and be sure that they are being synchronized (sent) to the remote machine.

Right now I have to work, zip the whole thing (big), send through scp the whole thing, etc.

Very time-consuming. :( :( :(

Any simple way to accomplish this? I heard about rsync but is it easy to do that with rsync? Step by step instructions will be very appreciated.

-Becky

Becky
  • 11
  • 1
    Yes, rsync is probably the right tool, although you'll have to either run it regularly or use inotify to make it happen automatically. But don't ask people to give step-by-step instructions here - you're expected to figure that out yourself and come with specific questions. – Andrew Schulman Sep 26 '14 at 19:12

2 Answers2

1

In the interest of being helpful, rsync is probably a good solution in your situation. The second example in the "Usage" section of the rsync man page (hint hint) has suited 80% of the situations I've needed it.

One high level setup which may suit your situation:

  • ensure the account running the mirror can log in via ssh keys from source to destination server

  • Test running the command by hand at least twice. The second time should be faster

  • add it to cron to run periodically (depending on your setup)

Another option could be to simply share the file system from one host to the other, negating the need for synchronization entirely, depending what you're doing.

EDIT: Apologies for my phone's inability to manage paragraphs

Andy
  • 1,111
  • 1
  • 7
  • 10
0

Depending on the use case I might consider using btsync. It's a multiplatform solution (Win/Lin/OS X) and at least on Linux it monitors the source directory with Inotify which is faster and more effective than repeated full directory scans especially if your source directory is large. Btsync does also do periodic directory scans to fully synchronize in case Inotify has missed some changes for whatever reason. Btsync also allows for multiple target hosts if you're in need of redundant multi-site backup solution and two-way synchronization is also available. Btsync is closed source, but it's free to use. Free as in no charge and free as in no license limitations for it's use afaik.

If you absolutely need ssh/scp and are not worried about getting your fingers dirty you could still use Inotify to fire the scp transfers. There are Inotify harnesses for various programming languages, I would probably pick pyinotify.