summaryrefslogtreecommitdiff
path: root/borgAuto.sh
blob: 62e83236aa31c5ca768e42dc7eb3f39cc51c84d0 (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
#!/usr/bin/bash
# 8 Sept 2019 SJ Pratt
# Copied from https://blog.andrewkeech.com/posts/170718_borg.html
# the envvar $REPONAME is something you should just hardcode
export REPOSITORY="/mnt/bak/st33vHome" 

# Fill in your password here, borg picks it up automatically
#export BORG_PASSPHRASE="" 

# Backup all of /home except a few excluded directories and files
borg create -v --stats  --compression lz4                 \
    $REPOSITORY::'{hostname}-{now:%Y-%m-%dT%H:%M}' /home/st33v \
--exclude '/home/*/.cache'                               \
--exclude '/home/$USER/cargo'                        \
--exclude '/home/st33v/.dropbox'                         \
--exclude '/home/st33v/.config'
--exclude '/home/lost+found'                             \
--exclude '*.img'                                        \
--exclude '*.iso'                                        \

# Backup olho
borg create -v --stats --compression none --progress     \
     '/mnt/bak/olho::{now}' /mnt/olho

# Route the normal process logging to journalctl
2>&1

 
# Prune the repo of extra backups
#borg prune -v $REPOSITORY --prefix '{hostname}-'         \
#    --keep-hourly=6                                      \
#    --keep-daily=7                                       \
#    --keep-weekly=4                                      \
#    --keep-monthly=6                                     \
 
# Include the remaining device capacity in the log
df -hl | grep --color=never /mnt/bak
 
borg list $REPOSITORY
 
exit 0