22 lines
690 B
Bash
Executable File
22 lines
690 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
echo "[+] Finding latest snapshot..."
|
|
latest_snapshot=$(ls /media/storage/backup/snapshots | sort | tail -n1)
|
|
passphrase=$(rage -d -i /media/storage/backup/static-passphrase-key /dev/shm/backup-passphrase)
|
|
|
|
echo "[+] Creating new snapshot..."
|
|
new_snapshot=$(date -Iminutes)
|
|
btrfs subvolume snapshot -r '/media/storage/backup/data' "/media/storage/backup/snapshots/$new_snapshot"
|
|
|
|
echo "[+] Encrypting new snapshot..."
|
|
btrfs send \
|
|
-p "/media/storage/backup/snapshots/$latest_snapshot" \
|
|
"/media/storage/backup/snapshots/$new_snapshot" \
|
|
| zstd - \
|
|
| simple-age-encryptor "$passphrase" \
|
|
> "/media/storage/backup/repo/$new_snapshot.zstd.age"
|
|
|
|
echo "[+] Done!"
|