This repository has been archived by the owner on Apr 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.sh
executable file
·70 lines (55 loc) · 2.04 KB
/
backup.sh
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
65
66
67
68
69
70
#!/bin/bash
#
# Author: ngrundmann
# Version: 0.1.1
#
DEST_PROTOCOL="" #which transfer type to use e.g.scp
DEST_USER="" #remote backup user
DEST_SERVER="" #remote host
DEST_DIR="" #remote backup folder
DIR_BACKUP="" #which folders should be backuped. seperated by spaces
GPG_ALGO="AES256" #algorithm for encryption e.g. aes-256
GPG_PASSPHRASE="" #passphrase for encryption
BU_SIZE="5000" #size of single backup containers in MB
DIR_TMP=/tmp/duplicity #temp directory
DIR_SCRIPT=/root/bin #script diretcory
DIR_LOG=/var/log/duplicity #log directory
### DON'T CHANGE ANYTHING DOWN HERE ###
PASSPHRASE=$GPG_PASSPHRASE
export PASSPHRASE
case $1 in
full)
for BU_DIR in $DIR_BACKUP
do
duplicity full --gpg-options "--cipher-algo $GPG_ALGO" --volsize $BU_SIZE --ssh-options="-oIdentityFile=/root/.ssh/ssh_login_backup" $BU_DIR $DEST_PROTOCOL://$DEST_USER@$DEST_SERVER/$DEST_DIR$BU_DIR >> $DIR_LOG$BU_DIR.log
done
;;
incr*)
for BU_DIR in $DIR_BACKUP
do
duplicity incr --gpg-options "--cipher-algo $GPG_ALGO" --volsize $BU_SIZE --ssh-options="-oIdentityFile=/root/.ssh/ssh_login_backup" $BU_DIR $DEST_PROTOCOL://$DEST_USER@$DEST_SERVER/$DEST_DIR$BU_DIR >> $DIR_LOG$BU_DIR.log
done
;;
remove)
for BU_DIR in $DIR_BACKUP
do
duplicity remove-all-but-n-full 3 --force --ssh-options="-oIdentityFile=/root/.ssh/ssh_login_backup" $DEST_PROTOCOL://$DEST_USER@$DEST_SERVER/$DEST_DIR$BU_DIR >> $DIR_LOG$BU_DIR.log
done
;;
status)
for BU_DIR in $DIR_BACKUP
do
duplicity collection-status --ssh-options="-oIdentityFile=/root/.ssh/ssh_login_backup" $DEST_PROTOCOL://$DEST_USER@$DEST_SERVER/$DEST_DIR$BU_DIR
done
;;
cleanup)
for BU_DIR in $DIR_BACKUP
do
duplicity cleanup --force --ssh-options="-oIdentityFile=/root/.ssh/ssh_login_backup" $DEST_PROTOCOL://$DEST_USER@$DEST_SERVER/$DEST_DIR$BU_DIR
done
;;
*)
echo "Usage: $SCRIPTNAME {full|incr|remove|status|cleanup}" >&2
;;
esac
exit 0