first commit
This commit is contained in:
commit
13b62aa0f2
1 changed files with 158 additions and 0 deletions
158
README.md
Normal file
158
README.md
Normal file
|
|
@ -0,0 +1,158 @@
|
||||||
|
# BORG backup e BORGMATIC install
|
||||||
|
|
||||||
|
[orig link](https://torsion.org/borgmatic/docs/how-to/set-up-backups/)
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
## 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
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo borgmatic init --encryption repokey
|
||||||
|
sudo borgmatic create --verbosity 1 --list --stats
|
||||||
|
sudo borgmatic list
|
||||||
|
sudo borgmatic list --archive orangepi5-plus-2025-10-06T14:21:23.549342
|
||||||
|
```
|
||||||
|
|
||||||
|
sudo nano /etc/systemd/system/borgmatic.service
|
||||||
|
|
||||||
|
```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
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
sudo nano /etc/systemd/system/borgmatic.timer
|
||||||
|
|
||||||
|
```sh
|
||||||
|
[Unit]
|
||||||
|
Description=Daily backup timer
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=*-*-* 16:30:00
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
sudo systemctl enable --now borgmatic.timer
|
||||||
|
|
||||||
Loading…
Reference in a new issue