Commit 8dff2df7 authored by Fjen Undso's avatar Fjen Undso
Browse files

add support for gpg key encryption

parent 834d94be
......@@ -5,7 +5,6 @@
#
# sftp note: ssh private/public key with no password is required
# if not using pwauth
# TODO: gpg key encryption
##### BEGIN SETTINGS
### system settings
......@@ -32,7 +31,8 @@ declare -r FTPPORT="" # leave empty for standard protocol port
declare -r FTPDIR="path/on/ftp"
declare -r FTPNUMBACKUPS=90
### gpg settings
declare -r GPGPASS="" # optional gpg symmetrical passphrase
declare -r GPGKEYID="" # gpg key id
declare -r GPGPASS="" # gpg symmetrical passphrase, if not using GPGKEYID
##### END SETTINGS
fail() {
......@@ -60,7 +60,7 @@ execftp() {
}
### Check prerequisites
for i in mydumper lftp mail tar ${COMPRESS%% *}; do
for i in mydumper lftp mail tar gpg ${COMPRESS%% *}; do
if [ ! "$(which $i)" ]; then
fail "Error: prerequisite $i not found in PATH"
fi
......@@ -105,11 +105,19 @@ done
cd -
### Encryption
if [ -n "$GPGPASS" ]; then
if [ -n "$GPGKEYID$GPGPASS" ]; then
echo "### Encryption..."
cd "$backupdir"
for i in *; do
gpg --symmetric --batch --passphrase "$GPGPASS" --cipher-algo AES256 "$i"
echo "encrypt: $i"
if [ -n "$GPGKEYID" ]; then
gpg -e -r "$GPGKEYID" "$i" \
&& rm "$i"
else
echo "$GPGPASS" \
| gpg -c --batch --passphrase-fd 0 --cipher-algo AES256 "$i" \
&& rm "$i"
fi
done
cd -
fi
......
Supports Markdown
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