initial commit
This commit is contained in:
96
borg/.borg/backup.sh
Executable file
96
borg/.borg/backup.sh
Executable file
@@ -0,0 +1,96 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
REPO="nas:~/borg"
|
||||
LOCAL=false
|
||||
else
|
||||
DISK="$1"
|
||||
LOCAL=true
|
||||
fi
|
||||
|
||||
if $LOCAL
|
||||
then
|
||||
#check if unlocked
|
||||
if [ -e "/dev/disk/by-label/$DISK" ]
|
||||
then
|
||||
echo "Disk already unlocked"
|
||||
else
|
||||
udisksctl unlock -b /dev/disk/by-partlabel/$DISK --key-file "$HOME/.keys/luks.key"
|
||||
fi
|
||||
#check if mounted
|
||||
if [ -e "/run/media/$USER/$DISK" ]
|
||||
then
|
||||
echo "Disk already mounted"
|
||||
else
|
||||
udisksctl mount -b /dev/disk/by-label/$DISK
|
||||
fi
|
||||
REPO="/run/media/$USER/$DISK/borg"
|
||||
fi
|
||||
|
||||
|
||||
ARCHIVE="$REPO::$HOSTNAME-$(date +%Y-%m-%dT%T)"
|
||||
SRC="$HOME"
|
||||
BORG_PASSPHRASE=""
|
||||
echo "Enter passphrase for $REPO:"
|
||||
read -s BORG_PASSPHRASE
|
||||
export BORG_PASSPHRASE
|
||||
|
||||
borg create --progress --stats --exclude-caches \
|
||||
--exclude $HOME/VirtualBox\ VMs \
|
||||
--exclude $HOME/.cache \
|
||||
--exclude $HOME/Downloads \
|
||||
--exclude $HOME/Photos \
|
||||
--exclude $HOME/Videos \
|
||||
--exclude $HOME/tmp \
|
||||
--exclude $HOME/.local/Steam \
|
||||
--exclude $HOME/.local/share/Steam \
|
||||
--exclude $HOME/Audio \
|
||||
--exclude $HOME/nas \
|
||||
--exclude $HOME/go \
|
||||
--exclude $HOME/.var/app/com.valvesoftware.Steam \
|
||||
$ARCHIVE $SRC && if ! $LOCAL; then date +%s > $HOME/.lastbak; fi
|
||||
|
||||
|
||||
|
||||
borg prune --stats --list --keep-within 1d --glob-archives "$HOSTNAME*" \
|
||||
-d 7 \
|
||||
-w 4 \
|
||||
-m 6 \
|
||||
-y 1 \
|
||||
$REPO
|
||||
|
||||
if $LOCAL
|
||||
then
|
||||
SRC=""
|
||||
if ! nmcli connection show --active | grep '^vt-net' > /dev/null
|
||||
then
|
||||
SRC="--from local"
|
||||
fi
|
||||
echo "backing up Photo archive..."
|
||||
cd "/run/media/$USER/$DISK/photos"
|
||||
git annex sync
|
||||
# set +e
|
||||
# git annex mirror --from=origin
|
||||
git annex get $SRC
|
||||
# set -e
|
||||
git annex sync
|
||||
echo "backing up Audio archive..."
|
||||
cd "/run/media/$USER/$DISK/audio"
|
||||
git annex sync
|
||||
### git annex mirror --from=origin
|
||||
git annex get $SRC
|
||||
git annex sync
|
||||
cd /
|
||||
udisksctl unmount -b "/dev/disk/by-label/$DISK"
|
||||
udisksctl lock -b "/dev/disk/by-partlabel/$DISK"
|
||||
else
|
||||
echo "Backing up Audo archive..."
|
||||
cd "$HOME/Audio"
|
||||
git annex copy --to origin > /dev/null
|
||||
echo "Backing up Photo archive..."
|
||||
cd "$HOME/Photos"
|
||||
git annex copy --to origin > /dev/null
|
||||
fi
|
||||
9
borg/.borg/bakage.sh
Executable file
9
borg/.borg/bakage.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
last=$(cat $HOME/.lastbak)
|
||||
time=$(date +%s)
|
||||
|
||||
age_s=$(( $time - $last ))
|
||||
age=$(( $age_s / 86400 ))
|
||||
|
||||
echo $age
|
||||
7
borg/.borg/i3status-bakage.sh
Executable file
7
borg/.borg/i3status-bakage.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
i3status | while :
|
||||
do
|
||||
read line
|
||||
echo "$(~/.borg/bakage.sh)d ★ ${line}" || exit 1
|
||||
done
|
||||
Reference in New Issue
Block a user