Syncthing is an open-source program that lets you sync files across multiple devices. This is a lifesaver if you want to mirror your main machine to a backup computer.
Installing
First let’s install syncthing on both of our machines:
Arch sudo pacman -S syncthing
Ubuntu sudo apt install syncthing
Fedora dnf install syncthing
.
configuring
After it’s installed, run it for the first time in a terminal on your main machine: syncthing
. It’ll open up a webpage with an address of localhost:8384. Do the same for the other machine so they can automatically pick up on each other’s ID’s for later.
It’ll prompt you to set a password, go ahead and do it.
By default, Syncthing creates a folder called Sync in ~/Sync
you can use that folder to sync your files. Or what I do is sync every separate directory I want both computers to have. As you saw, I have three directories I’m syncing.
Let’s create a test folder: on our main machine first mkdir ~/test
. Now back on Syncthing’s home page click “add folder” and fill it out like so:
On the sharing tab you’ll see the ID of the other computer pop up go ahead and choose it, if you don’t make sure you have syncthing open on both computers and you’ll see it populate.
Under file versioning I recommend you pick “trash can file versioning” for 15 days, even if you accidentally delete something it won’t be permanently deleted until after 15 days.
Leave “ignore patterns as default”.
And finally on the advanced tab make sure you have it like this:
You want to make sure the folder syncs the newest files first
You also want it to send and receive new changes if your using both computers interchangeably
And that’s it, click create and now go to your other machine.
You should see a pop-up on the other machine asking you to add the folder, click add and give it the same options as the other folder. The only difference would be in the advanced tab; if you’re strictly using that pc as a backup machine, select receive only, but if you use both computers (a laptop and a desktop) then choose send and receive.
After you created the folder you’ll see it on your Syncthing home screen and it’ll always pull for changes any time you edit the directory.
To remove a folder, click on the folder name then “edit” you’ll see the remove option. This will only remove it from being synced, not the folder on your local machine.
Autostart syncthing
Now I’ll teach how to auto-start syncthing. They’re multiple ways of doing it but the most efficient way I found, which makes the user owner of syncthing is by running syncthing --no-browser
& in your startup files. Either your .xinitrc or in the autostart dir. That’s it, one line. This way, syncthing starts up in the background without launching your browser every time you boot up.
That’s how you can sync up two machines to be mirrors of each other. You can even sync your git repos without having to pull down changes if you suddenly have to start working on your laptop.
Comments