mirror of
https://codeberg.org/hyperreal/bin
synced 2024-11-25 10:23:42 +01:00
Add btrfs-backup, rustupinst
This commit is contained in:
parent
b0535faf49
commit
dd4c0cbd90
49
btrfs-backup
Executable file
49
btrfs-backup
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
LOGFILE="/var/log/btrfs-backup.log"
|
||||||
|
SNAP_DATE=$(date '+%Y-%m-%d_%H%M%S')
|
||||||
|
HEALTHCHECKS_URL=""
|
||||||
|
|
||||||
|
# Check if device is mounted
|
||||||
|
if ! grep "/srv/backup" /etc/mtab >/dev/null; then
|
||||||
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Backup device is not mounted." | tee -a "$LOGFILE"
|
||||||
|
notify-send -i computer-fail "Backup device is not mounted"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
create_snapshot() {
|
||||||
|
if ! btrfs subvolume snapshot -r "$1" "${1}/.snapshots/$2-$SNAP_DATE" >/dev/null; then
|
||||||
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Error creating snapshot of $1" | tee -a "$LOGFILE"
|
||||||
|
notify-send -i computer-fail "Error creating snapshot of $1"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Create snapshot of $1: OK" | tee -a "$LOGFILE"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
send_snapshot() {
|
||||||
|
mkdir -p "/srv/backup/$SNAP_DATE"
|
||||||
|
if ! btrfs send -q "${1}/.snapshots/$2-$SNAP_DATE" | btrfs receive -q "/srv/backup/$SNAP_DATE"; then
|
||||||
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Error sending snapshot of $1 to /srv/backup" | tee -a "$LOGFILE"
|
||||||
|
notify-send -i computer-fail "Error sending snapshot of $1 to /srv/backup"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Send snapshot of $1 to /srv/backup: OK" | tee -a "$LOGFILE"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create root and home snapshots
|
||||||
|
create_snapshot "/" "root"
|
||||||
|
create_snapshot "/home" "home"
|
||||||
|
|
||||||
|
# Send root and home snapshots
|
||||||
|
send_snapshot "/" "root"
|
||||||
|
send_snapshot "/home" "home"
|
||||||
|
|
||||||
|
if ! curl -m 10 --retry 5 "$HEALTHCHECKS_URL"; then
|
||||||
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Error sending ping to healthchecks.io" | tee -a "$LOGFILE"
|
||||||
|
notify-send -i computer-fail "Error sending ping to healthchecks.io"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Send ping to healthchecks.io: OK"
|
||||||
|
fi
|
3
rustupinst
Executable file
3
rustupinst
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
Loading…
Reference in New Issue
Block a user