4 ms·
I tried to find the best solution (simple, secure, incremental, reliable...) and could not find the perfect candidate either. I finally ended up by sending enc
by xroche 12y ago
I tried to find the best solution (simple, secure, incremental, reliable...) and could not find the perfect candidate either.
I finally ended up by sending encrypted gpg tar files to a remote backup machine (you may want to cross-backup machines) (without using any intermediate file)
(sorry if formatting breaks)
#!/bin/bash
#
# list of local directories to be backuped
DIRS="/home /media"
# destination directory target
DEST="/data/backups"
# gpg encryption email
GPGEMAIL="homer@example.com"
# remote ssh as user@pachine
REMOTESSH="homer@backup.example.com."
# remote ssh additional args
REMOTESSHARGS="-i /root/.ssh/id_backup"
for i in ${DIRS} ; do
if test -d "$i" ; then
f=${DEST}/$(echo $i | tr '/' '_' | sed -e 's/^_//').tgz.gpg
tmp=${DEST}/_tmp
echo "backuping $i to remote $f encrypted with pgp" >&2
/bin/tar cf - ${i} \
| /usr/bin/gpg --quiet --batch --encrypt --compress-algo zlib --recipient ${GPGEMAIL} -o - \
| /usr/bin/ssh -p ${REMOTESSHARGS} -o BatchMode=yes -o Compression=no ${REMOTESSH} \
"cat > $tmp && mv $tmp ${f}"
else
echo "error: $d does not exist" >&2
fi
done