Commit 9eb652fe authored by Daniel STAN's avatar Daniel STAN

support for gpg sending

parent 3ce35e08
......@@ -2,6 +2,8 @@
source `dirname $0`/backup_config.sh
BTRFS=/sbin/btrfs
available_local () {
# TODO escape
btrfs sub list $FS_DIR | sed "s/^.* path $BACK_DIR\/\($PATTERN\)$/\1/; t; d"
......@@ -15,6 +17,14 @@ available_common () {
(available_remote && available_local) | sort | uniq -c | sed "s/^ *2 //; t; d"
}
btrfs_send () {
if [ -z "$GPG_E" ]; then
$BTRFS send "$@"
else
$BTRFS send "$@" | $GPG_E
fi
}
if [ "$1" = "available" ]; then
available_local
elif [ "$1" = "candidates" ]; then
......@@ -22,7 +32,7 @@ elif [ "$1" = "candidates" ]; then
available_common
elif [ "$1" = "fullsend" ]; then
SNAP=`available_local | sort | tail -n 1`
btrfs send $FS_DIR/$BACK_DIR/$SNAP | $REMOTE receive
btrfs_send $FS_DIR/$BACK_DIR/$SNAP | $REMOTE receive $SNAP
elif [ "$1" = "incsend" ]; then
SNAP=`available_local | sort | tail -n 1`
echo "Trying to send last snap $SNAP"
......@@ -33,7 +43,7 @@ elif [ "$1" = "incsend" ]; then
echo "Parent and Snap coincide ! Already sent ! Aborting"
exit 1
fi
btrfs send -p $FS_DIR/$BACK_DIR/$PARENT $FS_DIR/$BACK_DIR/$SNAP | $REMOTE receive
btrfs_send -p $FS_DIR/$BACK_DIR/$PARENT $FS_DIR/$BACK_DIR/$SNAP | $REMOTE receive $SNAP $PARENT
elif [ "$1" = "receive" ]; then
btrfs receive $FS_DIR/$BACK_DIR
fi
......
# command="/usr/bin/env ORIGIN=kugel /home/dstan/scripts-perso/backup-enc-recv ${SSH_ORIGINAL_COMMAND#* }",no-port-forwarding,no-X11-forwarding,no-pty
case "$(hostname)" in
"ailesv")
# Path to the backup fs
......@@ -27,15 +29,37 @@ case "$(hostname)" in
PATTERN=1d_.*
fi
;;
"kugel")
GPG_E="gpg -e -r daniel.stan@crans.org"
if [ "$ORIGIN" = "kugel" ]; then
# Path to the backup fs
FS_DIR=/home
# Path to the backup directory (form FS_DIR)
BACK_DIR=.snapshot
# Extra filter for volumes (sed syntax)
PATTERN="quick_.*"
# REMOTE command SSH
REMOTE="ssh dstan@gigapudding.crans.org -i /root/backup_kugel_giga /home/dstan/scripts-perso/backup-enc-recv"
else
# Path to the backup fs
FS_DIR=/mnt/backup
# Path to the backup directory (form FS_DIR)
BACK_DIR=ailesv
# Extra filter for volumes (sed syntax)
PATTERN=1d_.*
# REMOTE command SSH
REMOTE="ssh dstan@gigapudding.crans.org -i /root/backup_ailesv_giga /home/dstan/scripts-perso/backup-enc-recv"
fi
;;
*)
# Path to the backup fs
FS_DIR=/mnt/backup
# Path to the backup directory (form FS_DIR)
BACK_DIR=ailesv
# Extra filter for volumes (sed syntax)
PATTERN=1d_.*
echo "Unknown host !";
exit 1
;;
esac
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment