summaryrefslogtreecommitdiff
path: root/.local/bin/backups
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/backups')
-rwxr-xr-x.local/bin/backups/assimilate42
-rwxr-xr-x.local/bin/backups/borg-offsite25
-rwxr-xr-x.local/bin/backups/borg-onsite25
3 files changed, 42 insertions, 50 deletions
diff --git a/.local/bin/backups/assimilate b/.local/bin/backups/assimilate
new file mode 100755
index 0000000..0137650
--- /dev/null
+++ b/.local/bin/backups/assimilate
@@ -0,0 +1,42 @@
1#!/bin/sh
2# Full system backup with sudo borg
3
4# Validate argument - should either be onsite or offsite to specify location
5ERRMSG="error: please specify either onsite or offsite"
6[ $# -ne 1 ] && echo $ERRMSG && exit 1
7[ "$1" != "onsite" -a "$1" != "offsite" ] && echo $ERRMSG && exit 1
8
9# Set variables
10LOCATION="$1"
11SUDO_OPTS="--preserve-env=BORG_PASSCOMMAND,PASSWORD_STORE_DIR"
12CREATE_OPTS="--warning --stats --show-rc --exclude-caches --one-file-system"
13LOG="$HOME/.config/borg/log"
14
15# Hack to get repository passphrase from pass
16# The passcommand will be invoked as root, so use sudo to run it as the user calling the script
17# who owns the password store. The environmental variable PASSWORD_STORE_DIR is passed through
18# SUDO_OPTS to the borg commands, and then passed to this command from the borg command
19# by the same means. This allows custom password store locations to work with this script.
20export BORG_PASSCOMMAND="sudo $SUDO_OPTS -u $USER pass Borg-Backup/$(hostname)-onsite"
21
22# Backup root partition
23sudo $SUDO_OPTS borg create $CREATE_OPTS \
24 --exclude '/dev/*' \
25 --exclude '/proc/*' \
26 --exclude '/sys/*' \
27 --exclude '/tmp/*' \
28 --exclude '/mnt/*' \
29 --exclude '/media/*' \
30 "/mnt/onsite-backup/$(hostname)::root-{now:%Y-%m-%d}" / 2>>$LOG
31
32# Backup boot parition
33sudo $SUDO_OPTS borg create $CREATE_OPTS \
34 "/mnt/onsite-backup/$(hostname)::boot-{now:%Y-%m-%d}" /boot 2>>$LOG
35
36# Backup home partition
37sudo $SUDO_OPTS borg create $CREATE_OPTS \
38 "/mnt/onsite-backup/$(hostname)::home-{now:%Y-%m-%d}" /home 2>>$LOG
39
40# Backup var partition
41sudo $SUDO_OPTS borg create $CREATE_OPTS \
42 "/mnt/onsite-backup/$(hostname)::var-{now:%Y-%m-%d}" /var 2>>$LOG
diff --git a/.local/bin/backups/borg-offsite b/.local/bin/backups/borg-offsite
deleted file mode 100755
index dfc9c01..0000000
--- a/.local/bin/backups/borg-offsite
+++ /dev/null
@@ -1,25 +0,0 @@
1#!/bin/sh
2# Full system backup with Borg
3
4# Backup root partition
5sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \
6 --exclude '/dev/*' \
7 --exclude '/proc/*' \
8 --exclude '/sys/*' \
9 --exclude '/tmp/*' \
10 --exclude '/mnt/*' \
11 --exclude '/media/*' \
12 "/mnt/offsite-backup/titan::root-{now:%Y-%m-%d}" /
13
14# Backup boot parition
15sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \
16 "/mnt/offsite-backup/titan::boot-{now:%Y-%m-%d}" /boot
17
18# Backup home partition
19sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \
20 "/mnt/offsite-backup/titan::home-{now:%Y-%m-%d}" /home
21
22# Backup var partition
23sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \
24 "/mnt/offsite-backup/titan::var-{now:%Y-%m-%d}" /var
25
diff --git a/.local/bin/backups/borg-onsite b/.local/bin/backups/borg-onsite
deleted file mode 100755
index 658c425..0000000
--- a/.local/bin/backups/borg-onsite
+++ /dev/null
@@ -1,25 +0,0 @@
1#!/bin/sh
2# Full system backup with Borg
3
4# Backup root partition
5sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \
6 --exclude '/dev/*' \
7 --exclude '/proc/*' \
8 --exclude '/sys/*' \
9 --exclude '/tmp/*' \
10 --exclude '/mnt/*' \
11 --exclude '/media/*' \
12 "/mnt/onsite-backup/titan::root-{now:%Y-%m-%d}" /
13
14# Backup boot parition
15sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \
16 "/mnt/onsite-backup/titan::boot-{now:%Y-%m-%d}" /boot
17
18# Backup home partition
19sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \
20 "/mnt/onsite-backup/titan::home-{now:%Y-%m-%d}" /home
21
22# Backup var partition
23sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \
24 "/mnt/onsite-backup/titan::var-{now:%Y-%m-%d}" /var
25