This commit is contained in:
Malin Freeborn 2022-11-28 23:50:53 +01:00
parent 31b29ee394
commit 2decd8d08a
Signed by: andonome
GPG Key ID: 52295D2377F4D70F
2 changed files with 23 additions and 29 deletions

View File

@ -1,15 +1,19 @@
---
title: "unison"
tags: [ "documentation", "backups", "sync" ]
tags: [ "Documentation", "Backups" ]
---
Install unison on both machines, and on both make the `~/.unison` directory.
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).
> unison -version
Create the `~/.unison` directory on both machines.
Make a job called `backup`:
> vim ~/.unison/backup.prf
> vim ~/.unison/*backup*.prf
All jobs must end in `.prf`.
You can name the file anything, but it must end in .prf.
Here is an example job, which synchronizes the `~/music` directory with a remote machine.
@ -25,28 +29,18 @@ ignore=Name *.flac
```
The last command means it will ignore any file with a name ending in `.flac`.
Add a port with this line:
```
sshargs=-p 4444
```
## Automatic Runs
The first command means this will run but also confirm which files will be deleted, and which will be transferred, us `batch = true` instead.
Or you can deleted that line in the `.prf` file and run it with a flag:
> unison -batch *backup*.prf
Set unison to run with crontab or a systemd unit file to have directories synchronize automatically.
## Problem Solving
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`.
Check with:
> unison -version
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.

View File

@ -2,9 +2,17 @@
title: "bash_tricks"
tags: [ "Documentation", "System" ]
---
# Automatic mp3 Tagging
# Track Live Changes
/u/OneTurnMore on Reddit:
See changes in a file as it changes:
> tail -f *somefile*
See changes in a directory, as it changes:
> watch -d ls *directory*
# Automatic mp3 Tagging
> !/usr/bin/env bash
> IFS=$'\n'
@ -14,7 +22,7 @@ tags: [ "Documentation", "System" ]
One can also use
> sed s/\,[^\.]*$//
> sed s/\,[^\.]\*$//
... in order to avoid multiple full stops messing up syntax.
@ -32,13 +40,6 @@ Regular expressions (``regex'') looks for patterns and is used with find and gre
If the shell is set to find file ``a*b.txt'' then it will pass this first to regex, and hit items like `aab.txt' and `abb.txt'. If it finds nothing, it'll then use globbing, and interpret `a*b.txt' literally.
# Alias Expansion
> echo '"\C- ": shell-expand-line' >> ~/.inputrc
Reload bash, and you can use Ctrl+Space to expand an alias.
Type in `ll` (or any alias), then Ctrl+Space.
# Automatic Renaming
There are a bunch of files:
@ -50,7 +51,7 @@ There are a bunch of files:
* Column CV.tex
* tccv.cls
Goal: swap the word ``Column'' for ``Malin'' in all files.
Goal: swap the word "Column" for "Alice" in all files.
> IFS=$'\n'
@ -88,7 +89,6 @@ Add number to variables with:
# Finding Duplicate Files
> find . -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 15 > all-files.txt
... add blank line to top of first file.