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
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
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.
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:
unison
before even though it has an extensive (German) wiki.ubuntuusers.de article which covers automatisation quite well.
– dessert
May 27 '18 at 08:25
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:
rsync
. – PerlDuck May 26 '18 at 20:16rsync
command incrontab
. – John1024 May 26 '18 at 20:48rsync
twice. – John1024 May 26 '18 at 21:41