-
Notifications
You must be signed in to change notification settings - Fork 1
/
backup_to_box.sh
62 lines (52 loc) · 1.95 KB
/
backup_to_box.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
#!/usr/bin/env bash
## Remote backup script. Requires duplicity and Box account with WebDAV enabled
## Resources:
## http://duplicity.nongnu.org/docs.html
## https://wiki.archlinux.org/index.php/Duplicity#Example_backup_script
## https://help.ubuntu.com/community/DuplicityBackupHowto
CERT_NAME="cacert.pem"
MOZILLA_CA_CERT_STORE="https://curl.haxx.se/ca/cacert.pem"
WORK_DIR="$HOME/.duplicity"
if [ ! -d $WORK_DIR ]; then
printf "Creating missing directory at $WORK_DIR\n"
mkdir $WORK_DIR
fi
cd $WORK_DIR
# Make sure we can verify the SSL cert on the remote server
# using the Mozilla CA certificate store
curl --remote-name --silent --time-cond $CERT_NAME -o $CERT_NAME $MOZILLA_CA_CERT_STORE
# We use Python Keyring Lib to store the password for WebDAV
# https://pypi.python.org/pypi/keyring
# pip install keyring
# python -m keyring set Login boxwebdav
export FTP_PASSWORD="$(python -m keyring get Login boxwebdav)"
# Prompt for GPG key passphrase
printf "Enter decryption passphrase: "
read -s password
export PASSPHRASE=$password
enc_key=B4397A5E # Public GPG key
dest="webdavs://[email protected]/dav/backup_folder"
src="$HOME"
date
printf "Starting backup...\n"
duplicity --encrypt-key $enc_key \
--gpg-options "--pinentry-mode=loopback" \
--full-if-older-than 60D \
--num-retries 3 \
--asynchronous-upload \
--archive-dir="$src/.cache/duplicity" \
--log-file "$src/.cache/duplicity/duplicity.log" \
--exclude="$src/.cache" \
--exclude="$src/.local/share/Trash" \
--exclude="$src/.thumbnails" \
--exclude="$src/.Private" \
--exclude="$src/.PlayOnLinux" \
--exclude="$src/.pry_history" \
--exclude="$src/.wine" \
--exclude="$src/Downloads" \
--exclude="$src/Music" \
--exclude="$src/VirtualBox VMs" \
--ssl-cacert-file "$CERT_DIR/$CERT_NAME" \
"$src" "$dest"
unset PASSPHRASE
unset FTP_PASSWORD