aboutsummaryrefslogtreecommitdiff
path: root/scripts/backup.sh
blob: d347cf98c8100a978d180b12bfaf9204b1cd79ac (plain) (blame)
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
#!/usr/bin/env bash


#
# BorgBackup
#

if [ ! -d ~/UTCLOUD/ ]; then
    red "~/UTCLOUD not attached. Backup not started."
    exit 1
fi

if [ ! -d ~/borgbkp/ ]; then
    yellow "~/borgbkp/ repository doesn't exist. Downloading latest version from $R:borgbkp/ into ~/borgbkp"
    # The initial borg repo was created with:
    # $ borg init --append-only --encryption=keyfile ~/borgbkp
    # See also: https://borgbackup.readthedocs.io/en/stable/usage/notes.html#append-only-mode
    rsync --verbose --progress --stats --update --recursive ~/UTCLOUD/borgbkp/ ~/borgbkp
fi

yellow "Creating new borg archive entry"
borg create                        \
     --verbose                     \
     --stats                       \
     --progress                    \
     --compression lzma,9          \
     ~/borgbkp::'{hostname}-{now}' \
     ~/Nextcloud/                  \
     ~/.thunderbird/
     # add folders to be backed up here
green "Done"

yellow "Syncing ~/borgbkp to ~/UTCLOUD/borgbkp/"
rsync --verbose --progress --stats --update --recursive ~/borgbkp/ ~/UTCLOUD/borgbkp/
green "Done"

yellow "Syncing ~/borgbkp to $R:borgbkp/"
rsync --verbose --progress --stats --update --recursive ~/borgbkp/ "$R:borgbkp/"
green "Done"


#
# mr
#

yellow "Backing up git repos"
pushd ~/

mr -s master
mr -s status
mr -s -j16 update
mr -s hd
mr -s -j4 rsyncnet

popd

yellow "Syncing annex"
pushd ~/annex/

git annex sync

popd

green "Done"