From e7f6ee9b9b252e4af0e09cfee9a296ae14d993d8 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 5 Jun 2022 15:15:39 +0300 Subject: [PATCH] Added GPG encryption by passphrase --- backup.sh | 28 +++++++++++++++++++++++++++- config.sample | 11 ++++++----- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/backup.sh b/backup.sh index 981b08c..c305b74 100755 --- a/backup.sh +++ b/backup.sh @@ -101,10 +101,36 @@ do done # Compressing -cd ${prefix}/${stamp} && tar -czf ${prefix}/compressed/${stamp}.tgz * + +if [ "${do_quet}" == 0 ] +then + echo "Compressing" +fi + +find ${prefix}/${stamp} -maxdepth 1 -type f -not -name "*.gz" -exec gzip {} \; + +# Encrypting +if [ -n "${gpg_passphrase}" ] +then + if [ "${do_quet}" == 0 ] + then + echo "Encrypting" + fi + + find ${prefix}/${stamp} -maxdepth 1 -type f -exec bash -c "echo \"${gpg_passphrase}\" | gpg --batch --passphrase-fd 0 --symmetric \"{}\" && rm -f \"{}\"" \; +fi + +if [ "${do_quet}" == 0 ] +then + echo "Packing" +fi + +# Packing +cd ${prefix}/${stamp} && tar -cf ${prefix}/compressed/${stamp}.tar * rm -f $prefix/$stamp/* rmdir $prefix/$stamp + # Sending data if [ -n "${sshhost}" ] then diff --git a/config.sample b/config.sample index 0411020..b650c23 100644 --- a/config.sample +++ b/config.sample @@ -2,8 +2,9 @@ sqldump_prefix="docker exec -t db mysqldump" sql_list="dbname dbname2 dbname3:table:table" files_list="/path/to/folder1 /path/to/folder/2:subfolder:file_in_folder:subfodler/subsub" prefix='/path_to_temp_folder'; -sshhost='host'; -sshport=22; -sshuser='login'; -sshkey='/path_to_ssh_private_key'; -sshpath='/media/hdd2/backup'; +#gpg_passphrase='my_super_secret_key' +#sshhost='host'; +#sshport=22; +#sshuser='login'; +#sshkey='/path_to_ssh_private_key'; +#sshpath='/media/hdd2/backup';