summaryrefslogtreecommitdiffstats
path: root/backup/stream-tar-xz-gpg-ftp.sh
blob: 69dc8e414c469e796d16aca2c20b758985e259f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /bin/sh

# uid@backup-server.net

destproto=ftp
destserver=backup-server.net
destuid=user
destpwd=password

#
# gpg keys to encrypt to
# you need to import and sign those
# import:
#   gpg --import <file> 
#   gpg --recv-key 0x8ED60127
# sign:
#   gpg --sign-key 0x8ED60127
#
destencr1=0xB848A4B4
destencr2=0x8ED60127
destencr3=0x43681400

FOLDERS="\
 /opt-share \
 /opt-linux-x86 \
 /opt-linux-x86_64 \
 /srv \
 /home \
 /root \
 /etc \
 /var/lib/mysql \
 /var/spool/mail \
 /var/log \
 /var/lib/awstats \
 /usr/local/awstats"

bbname=backup-`hostname`-`date +%Y%m%d%H%M`

function do_ssh_tar() {

echo
echo BEGIN $bbname
date
echo

time nice -n 20 \
tar cf - $FOLDERS | \
xz --format=xz --check=crc64 --threads=4 -z -c - | \
gpg -e --recipient $destencr1 --recipient $destencr2 --recipient $destencr3 | \
curl -u $destuid:$destpwd $destproto://$destserver/$bbname.tar.xz.gpg -T -

echo target backup $destuid@$destserver:$bbname.tar.xz.gpg

echo
echo END $bbname
date
echo

}

do_ssh_tar >& $bbname.log &
disown $!
#do_ssh_tar 2>&1 | tee $bbname.log