3

I have folder-A on an ext HDD lets say HDD-A, and folder-B in ext HDD-B.

Is there a way to sync both folders automatically? either real-time or once a day at least

dessert
  • 39,982

3 Answers3

3

I use rsync Install rsync for tasks like that:

rsync -a "/path/to/hdd1/dir-a" "/path/to/hdd2/dir-b"

You can add a cron job to schedule the task, I recommend redirecting rsync’s output to a log file. E.g. to run it every 10 minutes and save the output in ~/logs/rsync.log:

*/10 * * * * rsync -a "/path/to/hdd1/dir-a" "/path/to/hdd2/dir-b" >~/logs/rsync.log

If you prefer a GUI you can use grsync Install grsync:

grsync

When you configured it to your needs, press Alt+R to display the correspondent command line.

dessert
  • 39,982
3

Unison

You can use unison to keep two paths synchronised bi-directionally. The good thing about using unison, as compared to simpler programs like rsync, is that it has built-in conflict resolution handling. For instance, if in pathA/foo.txt and pathB/foo.txt have both changed, the program needs to know which file you want.

Basic usage for unison is:

$ unison -auto path/to/A path/to/B

then it will try to keep the structures below path/to/A and path/to/B in sync. You can also add the -batch flag to make it work non-interactively, although conflicts will not get resolved this way.

Unison will save a state for each sync pair, so it will remember your preferences for conflict resolution. There are quite some options available for different use cases.

It is available in Ubuntu as package unison. A GUI version is also available as unison-gtk.

Warning As with all automatic synchronisation solutions, please first make yourself familiar with the program in a test environment. Also read the documentation thoroughly. It is easy to mess up and end up overwriting the wrong files.

Extended manual:

Related:

Sebastian Stark
  • 6,122
  • 19
  • 48
1

I can recommend FreeFileSync. It works fast and great.

FreeFileSync on Ubuntu

I'm using it for synchronization between HDDs, USB-flashes, SSHFS, Samba share and/or local folder.

Also it has real-time sync mode (named as RealTimeSync).

You can install as FlatPak:

sudo apt-get install flatpak
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install flathub org.freefilesync.FreeFileSync

It works great in conjunction with Meld (sudo apt-get install meld).
You need to open FreeFileSync options (Tools→Options) and then add the following to the first line:

 |        Description       |             Command line            |
 |  Compare files in Meld   |  meld "%item_path%" "%item_path2%"  |

as shown on screenshot:

FreeFileSync Tools→Options

N0rbert
  • 99,918
  • I like it, but the icons are text are really large on my system. I wish I could get from my screen, – crafter Feb 16 '19 at 10:11