local/bin/homesync: Backup .gnupg

master
Pierre Neidhardt 2019-01-23 00:07:13 +01:00
parent 10abe98ae2
commit 63c0201060
1 changed files with 30 additions and 7 deletions

View File

@ -1,24 +1,38 @@
#!/bin/sh
if [ "$1" = "-h" ]; then
usage() {
cat <<EOF>&2
Usage: ${0##*/}
Sync home folder:
Sync home folder.
Options:
-p: Push upstream.
-d DEVICE: Device where to store ~/.gnupg
EOF
exit
fi
}
OPT_UPDATE=false
if [ "$1" = "-p" ]; then
OPT_UPDATE=true
shift
fi
OPT_DEVICE=""
while getopts ":hd:p" opt; do
case $opt in
h)
usage
exit ;;
p)
OPT_UPDATE=true ;;
d)
OPT_DEVICE="$OPTARG" ;;
\?)
usage
exit 1 ;;
esac
done
shift $(($OPTIND - 1))
PERSONAL_FOLDER="$HOME/personal"
[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config"
@ -37,6 +51,15 @@ message() {
echo -e "$YELLOW:: $@$NORMAL"
}
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 umount /mnt
sudo cryptsetup close gpg_backup
fi
section "$HOME/.package-lists"
package-lister