local/bin/homesync: Backup GPG on btrfs

master
Pierre Neidhardt 2019-05-09 23:38:40 +02:00
parent a7395183dd
commit c7275a2aa3
1 changed files with 5 additions and 2 deletions

View File

@ -88,8 +88,11 @@ done
if [ -n "$OPT_DEVICE" ]; then
section "GnuPG"
sudo cryptsetup open "$OPT_DEVICE" gpg_backup
sudo mount /dev/mapper/gpg_backup /mnt
tar -C ~ --exclude='*.conf' -cf /mnt/gnugpg-backup-$(date +%F).tar .gnupg
sudo mount -o compress=zstd /dev/mapper/gpg_backup /mnt
gpg --import /mnt/public/.gnupg/pubring.gpg
sudo btrfs subvolume snapshot -r /mnt/public /mnt/.snapshots/public_${*date +%F_%R} && \
rm -rfv /mnt/public/.gnupg && \
cp -a ~/.gnupg /mnt/public/
sudo umount /mnt
sudo cryptsetup close gpg_backup
fi