2022-01-16 18:20:39 +00:00
|
|
|
---
|
|
|
|
title: "unison"
|
2022-02-07 09:58:16 +00:00
|
|
|
tags: [ "documentation", "backups", "sync" ]
|
2022-01-16 18:20:39 +00:00
|
|
|
---
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
Install unison on both machines, and on both make the `~/.unison` directory.
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
Make a job called `backup`:
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
> vim ~/.unison/backup.prf
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
All jobs must end in `.prf`.
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
Here is an example job, which synchronizes the `~/music` directory with a remote machine.
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
```
|
2020-01-02 00:04:35 +00:00
|
|
|
auto = true
|
2022-01-26 20:38:31 +00:00
|
|
|
root=/home/ghost
|
|
|
|
root=ssh://ghost@192.168.0.10//home/ghost/
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
path=music
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
ignore=Name *.flac
|
2020-01-02 00:04:35 +00:00
|
|
|
|
|
|
|
```
|
2022-01-26 20:38:31 +00:00
|
|
|
The last command means it will ignore any file with a name ending in `.flac`.
|
|
|
|
|
2022-02-07 09:58:16 +00:00
|
|
|
Add a port with this line:
|
|
|
|
|
|
|
|
```
|
|
|
|
sshargs=-p 4444
|
|
|
|
```
|
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
## Automatic Runs
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
The first command means this will run but also confirm which files will be deleted, and which will be transferred, us `batch = true` instead.
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
Set unison to run with crontab or a systemd unit file to have directories synchronize automatically.
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-02-07 09:58:16 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
## Problem Solving
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
Unison is extremely sensitive to version changes.
|
|
|
|
Both machines must have exactly the same version of unison installed, as well as the same version of `ocaml`.
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
Check with:
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
> unison -version
|
2020-01-02 00:04:35 +00:00
|
|
|
|
2022-01-26 20:38:31 +00:00
|
|
|
You will see data files summarizing what has happened in the `~/.unison` directory.
|
|
|
|
If something goes wrong, you may be prompted to delete these to start again.
|
2020-01-02 00:04:35 +00:00
|
|
|
|