added encryption support and fixed a couple of comments

This commit is contained in:
Von Random 2015-01-13 12:53:59 +03:00
parent 175c7979f9
commit b5d0158936
2 changed files with 19 additions and 3 deletions

View file

@ -31,6 +31,10 @@ source_dirs=( '/home/user/source1:/var/backup/snapshot.list'
## externally.
#backup_filename='somebackup'
## GPG key to encrypt backups, uses name of the private
## key in your keyring
#gnupg_key='keyname'
#### remote options ####
## Remote host.
remote_host='hostname.tld'

View file

@ -1,5 +1,7 @@
#!/usr/bin/env zsh
self_name=$0
# some hardcoded defaults
default_cfg='/etc/backup.zsh.cfg'
default_postfix=$(date +%F-%H%M)
default_ftp_port='21'
@ -104,7 +106,7 @@ function generate_fullpath
backup_type='full'
fi
if [[ -z $backup_filename ]]; then
outfile="$backup_dir/${local_host}-${src_basename}_${postfix}_${backup_type}.t${compress_format:-'ar'}"
outfile="$backup_dir/${local_host}-${src_basename}_${postfix}_${backup_type}${gnupg_key:+'.gpg.'}.t${compress_format:-'ar'}"
else
outfile=$backup_filename
fi
@ -136,7 +138,13 @@ function store
esac
}
# self explanatory, using case statement, so no one dash multiple opts supported
# encrypt asymmetrically via gpg
function encrypt
{
gpg -r $gnupg_key -e -
}
# self explanatory, using case statement, so one dash multiple opts is not supported
function parse_opts
{
while [[ -n $1 ]]; do
@ -171,7 +179,11 @@ function main
generate_fullpath
err "Creating a backup of $source_dir via $protocol to store it in $outfile."
# pipe magic into magic
compress | store
if [[ -n $gnupg_key ]]; then
compress | encrypt | store
else
compress | store
fi
done
return 0
}