210 lines
5.2 KiB
Markdown
210 lines
5.2 KiB
Markdown
# BORG backup e BORGMATIC install
|
|
|
|
[orig link](https://torsion.org/borgmatic/docs/how-to/set-up-backups/)
|
|
|
|
[orig2 link](https://linuxconfig.org/how-to-orchestrate-borg-backups-with-borgmatic)
|
|
|
|
## Aprire un flusso automatico (senza password) con SSH
|
|
|
|
[orig link](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
|
|
|
|
Creare la key dal quale si vuole entrare con SSH senza login (x es 192.168.1.3)
|
|
|
|
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "Coppia chiavi SSH di tuo nome"
|
|
|
|
Copiarle sul client dove si vuole entrare (x es. 192.168.1.4)
|
|
|
|
ssh-copy-id orangepi@192.168.1.4
|
|
|
|
## BORG install
|
|
|
|
### Installare le dipendenze
|
|
|
|
```bash
|
|
sudo apt-get install python3 python3-dev python3-pip python3-virtualenv \
|
|
libacl1-dev \
|
|
libssl-dev \
|
|
liblz4-dev libzstd-dev libxxhash-dev \
|
|
build-essential pkg-config
|
|
sudo apt-get install libfuse-dev fuse # needed for llfuse
|
|
sudo apt-get install libfuse3-dev fuse3 # needed for pyfuse3
|
|
```
|
|
|
|
### Installare borg
|
|
|
|
sudo apt install borgbackup
|
|
|
|
### Utilizzare solo borg senza borgmatic
|
|
|
|
[link](https://borgbackup.readthedocs.io/en/1.4-maint/quickstart.html)
|
|
[link2](https://linuxconfig.org/how-to-orchestrate-borg-backups-with-borgmatic)
|
|
[link3](https://community.hetzner.com/tutorials/install-and-configure-borgmatic)
|
|
|
|
Before a backup can be made a repository has to be initialized:
|
|
|
|
borg init --encryption=repokey /path/to/repo
|
|
|
|
Backup the ~/src and ~/Documents directories into an archive called Monday:
|
|
|
|
borg create /path/to/repo::Monday ~/src ~/Documents
|
|
|
|
The next day create a new archive called Tuesday:
|
|
|
|
borg create --stats /path/to/repo::Tuesday ~/src ~/Documents
|
|
|
|
List all archives in the repository:
|
|
|
|
|
|
borg list /path/to/repo
|
|
|
|
```sh
|
|
Monday Mon, 2016-02-15 19:14:44
|
|
Tuesday Tue, 2016-02-16 19:15:11
|
|
```
|
|
|
|
List the contents of the Monday archive:
|
|
|
|
borg list /path/to/repo::Monday
|
|
|
|
```sh
|
|
drwxr-xr-x user group 0 Mon, 2016-02-15 18:22:30 home/user/Documents
|
|
-rw-r--r-- user group 7961 Mon, 2016-02-15 18:22:30 home/user/Documents/Important.doc
|
|
...
|
|
```
|
|
|
|
Restore the Monday archive by extracting the files relative to the current directory:
|
|
|
|
borg extract /path/to/repo::Monday
|
|
|
|
Delete the Monday archive (please note that this does not free repo disk space):
|
|
|
|
borg delete /path/to/repo::Monday
|
|
|
|
## BORG in MacOs
|
|
|
|
Se si vuole anche solo salvare si MacOs si deve installare amche sul sistema macOS
|
|
|
|
installare con
|
|
|
|
```sh
|
|
brew install --cask macfuse
|
|
brew install borgbackup/tap/borgbackup-fuse
|
|
```
|
|
|
|
oppure senza macfuse
|
|
|
|
```sh
|
|
brew install borgbackup
|
|
```
|
|
|
|
per utilizzarlo inserire il remote path di BORG nel comando, per esempio dal server 192.168.1.4
|
|
|
|
sudo borg init --remote-path /usr/local/bin/borg --encryption=repokey ssh://fabio@192.168.1.2/Volumes/SSD4T/OPi5_backup/DockerComposeServer.borg
|
|
|
|
sudo borg create --compression lzma --remote-path /usr/local/bin/borg ssh://fabio@192.168.1.2/Volumes/SSD4T/OPi5_backup/DockerComposeServer.borg::updated_$(date +"%Y-%b-%d-%T") /home/nvme/docker/volumes/portainer_data/_data/compose
|
|
|
|
sudo borg list --remote-path /usr/local/bin/borg ssh://fabio@192.168.1.2/Volumes/SSD4T/OPi5_backup/DockerComposeServer.borg
|
|
|
|
sudo borg list --remote-path /usr/local/bin/borg ssh://fabio@192.168.1.2/Volumes/SSD4T/OPi5_backup/DockerComposeServer.borg::updated_2025-Oct-09-14:40:4
|
|
|
|
PS per vedere gli errori di collegamento utilizzare
|
|
|
|
export BORG_RSH="ssh -v"
|
|
|
|
## Borgmatic Install
|
|
|
|
sudo apt install borgmatic
|
|
|
|
poi si genera il file config
|
|
|
|
mkdir -p ~/.config/borgmatic && generate-borgmatic-config
|
|
|
|
in questo caso il file è
|
|
|
|
/etc/borgmatic/config.yaml
|
|
|
|
altrimenti si specifica la dir con -d
|
|
|
|
sudo mkdir -p ~/.config/borgmatic && sudo generate-borgmatic-config -d ~/.config/borgmatic/config.yaml
|
|
|
|
e si deve editare
|
|
|
|
sudo nano ~/.config/borgmatic/config.yaml
|
|
|
|
```bash
|
|
source_directories:
|
|
- /home/orangepi/Documenti
|
|
exclude_patterns:
|
|
- /home/orangepi/Documenti/c
|
|
repositories:
|
|
- path: ssh://orangepi@192.168.1.4/home/nvme/prova/miosudo.borg
|
|
label: backupserver
|
|
keep_daily: 7
|
|
keep_weekly: 4
|
|
keep_monthly: 6
|
|
keep_yearly: 1
|
|
```
|
|
|
|
si inizializza l'archivio
|
|
|
|
sudo borgmatic init --encryption repokey
|
|
|
|
si crea l'archivio
|
|
|
|
sudo borgmatic create --verbosity 1 --list --stats
|
|
|
|
si listano tutti gli archivi
|
|
|
|
sudo borgmatic list
|
|
|
|
si verifica cosa c'è in un archivio
|
|
|
|
sudo borgmatic list --archive orangepi5-plus-2025-10-06T14:21:23.549342
|
|
|
|
### Programmare in systemd un servizio per borg "borgmatic.service"
|
|
|
|
sudo nano /etc/systemd/system/borgmatic.service
|
|
|
|
ed inserire
|
|
|
|
```sh
|
|
[Unit]
|
|
Description=Borgmatic system backup
|
|
Requires=network.target
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
Nice=10
|
|
IOSchedulingClass=best-effort
|
|
IOSchedulingPriority=6
|
|
ProtectSystem=full
|
|
ExecStart=/usr/bin/borgmatic --verbosity -1 --syslog-verbosity 1
|
|
```
|
|
|
|
inserire un timer da usare con systemd
|
|
|
|
sudo nano /etc/systemd/system/borgmatic.timer
|
|
|
|
e inserire
|
|
|
|
```sh
|
|
[Unit]
|
|
Description=Daily backup timer
|
|
|
|
[Timer]
|
|
OnCalendar=*-*-* 16:30:00
|
|
Persistent=true
|
|
|
|
[Install]
|
|
WantedBy=timers.target
|
|
```
|
|
|
|
abilitare il servizio
|
|
|
|
sudo systemctl enable --now borgmatic.timer
|
|
|
|
verificare lo status
|
|
|
|
sudo systemctl status borgmatic.timer
|
|
|