lk/data/backups/unison.md

56 lines
1.3 KiB
Markdown
Raw Normal View History

2022-01-16 18:20:39 +00:00
---
title: "unison"
2022-11-28 22:50:53 +00:00
tags: [ "Documentation", "Backups" ]
2022-01-16 18:20:39 +00:00
---
2020-01-02 00:04:35 +00:00
2022-11-28 22:50:53 +00:00
Install unison on both machines, and make sure both have the same version of unison, with the same version of the ocaml compiler (the smallest difference will cause problems).
```bash
unison -version
```
2022-11-28 22:50:53 +00:00
Create the `~/.unison` directory on both machines.
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
```bash
JOB=backup
```
2020-01-02 00:04:35 +00:00
Here is an example job, which synchronizes the `~/music` directory with a remote machine which has the same username.
2020-01-02 00:04:35 +00:00
```bash
echo "
2020-01-02 00:04:35 +00:00
auto = true
root=$HOME
root=ssh://$USER@$IP_ADDRESS/$HOME
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
" > ~/.unison/"$JOB".prf
2020-01-02 00:04:35 +00:00
```
Remember to specify `$IP_ADDRESS`
2022-01-26 20:38:31 +00:00
The last command means it will ignore any file with a name ending in `.flac`.
## 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.
2022-11-28 22:50:53 +00:00
Or you can deleted that line in the `.prf` file and run it with a flag:
```bash
unison -batch *backup*.prf
```
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-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
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