Add btrbk section to README
Add instructions for setting up btrbk on fedora.
This commit is contained in:
@@ -124,3 +124,109 @@ Download RPM from https://github.com/TheAssassin/AppImageLauncher/releases/tag/v
|
|||||||
```bash
|
```bash
|
||||||
ansible-playbook --ask-become-pass ansible/framework_fedora.yml
|
ansible-playbook --ask-become-pass ansible/framework_fedora.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## BTRBK
|
||||||
|
|
||||||
|
### Create Encrypted Drive
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Create an encrypted drive
|
||||||
|
sudo cryptsetup luksFormat
|
||||||
|
|
||||||
|
# LUKS Disk Encryption can use up to 8 key slots to store passwords. We can use these keys to auto mount LUKS device.
|
||||||
|
# cryptsetup luksDump /dev/sda
|
||||||
|
|
||||||
|
# Create a lukskeys
|
||||||
|
mkdir -p /home/ducoterra/.lukskeys
|
||||||
|
|
||||||
|
# Generate key
|
||||||
|
dd if=/dev/random bs=32 count=1 of=/home/ducoterra/.lukskeys/btr_backup
|
||||||
|
|
||||||
|
# Change key mode
|
||||||
|
chmod 600 /home/ducoterra/.lukskeys
|
||||||
|
|
||||||
|
# Luks add a key
|
||||||
|
sudo cryptsetup luksAddKey /dev/sda /home/ducoterra/.lukskeys/btr_backup
|
||||||
|
|
||||||
|
# Get UUID of disk with
|
||||||
|
sudo blkid /dev/sda1
|
||||||
|
|
||||||
|
# Add key to crypttab
|
||||||
|
echo 'btr_backup UUID=1d7ce570-e695-47a0-9dda-5f14b5b20e21 /home/ducoterra/.lukskeys/btr_backup luks' >> /etc/crypttab
|
||||||
|
|
||||||
|
# Create read-only backup mount point
|
||||||
|
sudo btrfs sub create /mnt/btr_backup
|
||||||
|
sudo btrfs property set /mnt/btr_backup ro true
|
||||||
|
|
||||||
|
# Add to fstab
|
||||||
|
echo '/dev/mapper/btr_backup /mnt/btr_backup btrfs x-systemd.device-timeout=0,x-gvfs-show,x-gvfs-name=btr_backup,ssd,nofail,noatime,discard=async,compress=zstd 0 0' >> /etc/fstab
|
||||||
|
|
||||||
|
# mount
|
||||||
|
sudo cryptsetup luksOpen /dev/disk/by-uuid/1d7ce570-e695-47a0-9dda-5f14b5b20e21 backup0 --key-file=/home/ducoterra/.lukskeys/backup0
|
||||||
|
|
||||||
|
# close (or fix issues)
|
||||||
|
sudo cryptsetup luksClose backup0
|
||||||
|
```
|
||||||
|
|
||||||
|
### Create BTRBK Config
|
||||||
|
|
||||||
|
`sudo vim /etc/btrbk/btrbk.conf`
|
||||||
|
|
||||||
|
```conf
|
||||||
|
snapshot_create ondemand
|
||||||
|
snapshot_preserve_min 2d
|
||||||
|
snapshot_preserve 14d
|
||||||
|
snapshot_dir snapshots
|
||||||
|
|
||||||
|
target_preserve_min no
|
||||||
|
target_preserve 20d 10w *m
|
||||||
|
|
||||||
|
volume /mnt/btr_pool
|
||||||
|
target /mnt/btr_backup
|
||||||
|
subvolume root
|
||||||
|
subvolume home
|
||||||
|
```
|
||||||
|
|
||||||
|
### Create Systemd Timer
|
||||||
|
|
||||||
|
`sudo vim /etc/systemd/system/btrbk.service`
|
||||||
|
|
||||||
|
```conf
|
||||||
|
[Unit]
|
||||||
|
Description=Runs btrbk with config file at /etc/btrbk/btrbk.conf
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=btrbk -c /etc/btrbk/btrbk.conf -v run
|
||||||
|
```
|
||||||
|
|
||||||
|
`sudo vim /etc/systemd/system/btrbk.timer`
|
||||||
|
|
||||||
|
```conf
|
||||||
|
[Unit]
|
||||||
|
Description=Run btrbk every hour
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=hourly
|
||||||
|
AccuracySec=10min
|
||||||
|
Persistent=true
|
||||||
|
Unit=btrbk.service
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
|
```
|
||||||
|
|
||||||
|
### Test, Start and Enable service
|
||||||
|
|
||||||
|
Test your service:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo btrbk -c /etc/btrbk/btrbk.conf -v run
|
||||||
|
```
|
||||||
|
|
||||||
|
Enable your service:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo systemctl start btrbk.timer
|
||||||
|
|
||||||
|
sudo systemctl enable btrbk.timer
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user