-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathborgsnap
More file actions
executable file
·32 lines (24 loc) · 1.04 KB
/
borgsnap
File metadata and controls
executable file
·32 lines (24 loc) · 1.04 KB
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
#!/usr/bin/env bash
set -o nounset
set -o errexit
function debug {
echo $1
true
}
debug "Starting backup of $HOSTNAME"
#what dirs do you want to be backed up?
source /usr/local/etc/borgsnap.conf || BACKUP_DIRS=""
if [ -z "$BACKUP_DIRS" ]; then
echo "WARNING: There is no /usr/local/etc/borgsnap.conf - creating one with a default value..."
echo 'BACKUP_DIRS="/etc /root/ /var/backups/ /var/log/ /var/www /home"' | tee -a /usr/local/etc/borgsnap.conf
chown root: /usr/local/etc/borgsnap.conf
chmod 0600 /usr/local/etc/borgsnap.conf
source /usr/local/etc/borgsnap.conf
fi
#to set up: "cat > /usr/local/etc/borgpass && sudo chmod 600 /usr/local/etc/borgpass" - paste password and hit return then Ctrl+D
BORG_PASSPHRASE="$(cat /usr/local/etc/borgpass)"
BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
export BACKUP_DIRS BORG_PASSPHRASE BORG_RELOCATED_REPO_ACCESS_IS_OK
debug "Starting actual backup"
borg create -C zlib "ssh://borg@shop.makerslocal.org:22222//srv/backup/borg/repos/$HOSTNAME::rootfs-$(date +%s)" $BACKUP_DIRS
debug "Backup of $HOSTNAME complete"