Files
bikinibottom/On host/borg-server.md
2025-10-18 18:14:47 +02:00

2.6 KiB

Borg Server / Borg Backup

Install Borg

sudo apt install borgbackup -y

Repository initialization on server :

Classic repo

borg init -e none /mnt/data/backup/<repo_name>

Repository initialization from distant host :

# 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

# 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.

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 :

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 :

# 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:

# 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 :

# 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 :

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 :

# 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

# local
borg compact /mnt/data/backup

# distant
borg compact ssh://pleb@krabs/mnt/data/backup

Prune and keep lastest 2 backups

# local
borg prune --keep-last 2 /mnt/data/backup

# distant
borg prune --keep-last 2 ssh://pleb@krabs/mnt/data/backup