sync two folders on two separate ext HDD
I use 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
:
When you configured it to your needs, press Alt+R to display the correspondent command line.
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:
- https://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html
Related:
- syncronizing with unison on ubuntu
- Unison - Automatically Sync Computers
I can recommend FreeFileSync. It works fast and great.
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: