119 lines
2.6 KiB
Markdown
119 lines
2.6 KiB
Markdown
Borg Server / Borg Backup
|
|
===
|
|
#### Install Borg
|
|
```bash
|
|
sudo apt install borgbackup -y
|
|
```
|
|
|
|
### Repository initialization on server :
|
|
#### Classic repo
|
|
```bash
|
|
borg init -e none /mnt/data/backup/<repo_name>
|
|
```
|
|
### Repository initialization from distant host :
|
|
```bash
|
|
# local
|
|
borg init -e none /mnt/data/backup/<repo_name>
|
|
|
|
# distant
|
|
borg init -e none ssh://pleb@krabs/mnt/data/backup/<repo_name>
|
|
```
|
|
|
|
#### Encrypted repo
|
|
```bash
|
|
# local
|
|
borg init -e repokey /mnt/data/backup/<repo_name>
|
|
|
|
# distant
|
|
borg init -e repokey ssh://pleb@krabs/mnt/data/backup/<repo_name>
|
|
```
|
|
> Enter a passphrase to encrypt the folder.
|
|
```txt
|
|
Enter new passphrase:
|
|
Enter same passphrase again:
|
|
IMPORTANT: you will need both KEY AND PASSPHRASE to access this repo!
|
|
If you used a repokey mode, the key is stored in the repo, but you should back it up separately.
|
|
Use "borg key export" to export the key, optionally in printable format.
|
|
Write down the passphrase. Store both at safe place(s).
|
|
```
|
|
|
|
### Create a backup :
|
|
```bash
|
|
cd /path/to/folder
|
|
|
|
# local
|
|
borg create --progress --stats -C zstd,10 /mnt/data/backup/<repo_name>::20251018 .
|
|
|
|
# distant
|
|
borg create --progress --stats -C zstd,10 ssh://pleb@krabs/mnt/data/backup/<repo_name>::20251018 .
|
|
```
|
|
|
|
### List a backup :
|
|
```bash
|
|
# local
|
|
borg list /mnt/data/backup/<repo_name>::20251018
|
|
|
|
# distant
|
|
borg list ssh://pleb@krabs/mnt/data/backup/<repo_name>::20251018
|
|
```
|
|
|
|
### Verify the backup folder using the command info:
|
|
```bash
|
|
# local
|
|
borg info /mnt/data/backup/<repo_name>::20251018
|
|
|
|
# distant
|
|
borg info ssh://pleb@krabs/mnt/data/backup/<repo_name>::20251018
|
|
```
|
|
|
|
### Restore a backup to a folder :
|
|
```bash
|
|
# local
|
|
borg extract --progress /mnt/data/backup/<repo_name>::20251018 /path/to/folder
|
|
|
|
# distant
|
|
borg extract --progress ssh://pleb@krabs/mnt/data/backup/<repo_name>::20251018 /path/to/folder
|
|
```
|
|
|
|
### Mount a backupr :
|
|
```bash
|
|
mkdir /var/tmp/<folder_name>
|
|
|
|
# local
|
|
borg mount /mnt/data/backup/<repo_name>::20251018 /var/tmp/<folder_name>
|
|
|
|
# distant
|
|
borg mount ssh://pleb@krabs/mnt/data/backup/<repo_name>::20251018 /var/tmp/<folder_name>
|
|
|
|
# unmount
|
|
borg unmount var/tmp/<folder_name>
|
|
```
|
|
|
|
### Delete a backup :
|
|
```bash
|
|
# local
|
|
borg delete /mnt/data/backup/<repo_name>::20251018
|
|
|
|
# distant
|
|
borg delete ssh://pleb@krabs/mnt/data/backup/<repo_name>::20251018
|
|
```
|
|
|
|
### Freeup space
|
|
#### Compact space
|
|
```bash
|
|
# local
|
|
borg compact /mnt/data/backup
|
|
|
|
# distant
|
|
borg compact ssh://pleb@krabs/mnt/data/backup
|
|
```
|
|
|
|
#### Prune and keep lastest 2 backups
|
|
```bash
|
|
# local
|
|
borg prune --keep-last 2 /mnt/data/backup
|
|
|
|
# distant
|
|
borg prune --keep-last 2 ssh://pleb@krabs/mnt/data/backup
|
|
```
|