summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-10-28 12:09:57 +0200
committerDaniel Weipert <code@drogueronin.de>2023-10-28 12:09:57 +0200
commit47d30b3c5b10812010c25ced00e4b418c37f8aa3 (patch)
tree649cb023e4109058261ae40b0d991aed24c0e6aa
parentb9b21873c0d7ba1ab6dd5cc70d16e69bcd57fb27 (diff)
backup implementation, enhancements and fixesHEADmain
-rw-r--r--.config/borg/.env-backup.example2
-rwxr-xr-x.config/yadm/bootstrap41
-rwxr-xr-x.local/bin/backup-prune6
-rwxr-xr-x.local/bin/backup-run5
-rwxr-xr-x.local/bin/shutdown-run6
-rwxr-xr-x.local/bin/update1
-rw-r--r--.zshrc6
-rw-r--r--Applications/NextCloud/.env.example8
-rw-r--r--Applications/NextCloud/bin/fstab8
-rw-r--r--Applications/NextCloud/docker-compose.yml1
10 files changed, 74 insertions, 10 deletions
diff --git a/.config/borg/.env-backup.example b/.config/borg/.env-backup.example
new file mode 100644
index 0000000..700aaeb
--- /dev/null
+++ b/.config/borg/.env-backup.example
@@ -0,0 +1,2 @@
+export BORG_REPO="/media/backup"
+export BACKUP_PATH="/media/files"
diff --git a/.config/yadm/bootstrap b/.config/yadm/bootstrap
index 2f26097..0cccda6 100755
--- a/.config/yadm/bootstrap
+++ b/.config/yadm/bootstrap
@@ -4,13 +4,48 @@ sudo pacman -Sy \
zsh neovim man-db \
eza btop cron \
python \
+ borg smartmontools \
firefox \
docker docker-compose
-chsh -s /bin/zsh
usermod -a -G docker $(whoami)
sudo systemctl enable docker.service --now
-CRON_UPDATE="0 3 * * * update"
-(crontab -l; echo "$CRON_UPDATE") | crontab -
+
+#
+# Shell
+#
+
+chsh -s /bin/zsh
+
+ZSH=$HOME/.config/zsh/ohmyzsh
+if [ ! -d "$ZSH" ]; then
+ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
+fi
+
+
+#
+# System
+#
+
+sed -i 's/#HandleLidSwitch=suspend/HandleLidSwitch=ignore/' /etc/systemd/logind.conf
+
+sed -i 's/# %wheel/%wheel/' /etc/sudoers
+
+#CRON_UPDATE="0 3 * * * update"
+#(crontab -l; echo "$CRON_UPDATE") | crontab -
+
+
+# Backup
+
+#CRON_BACKUP_RUN="0 4 * * * backup-run"
+#(crontab -l; echo "$CRON_BACKUP_RUN") | crontab -
+
+#CRON_BACKUP_PRUNE="0 4 * * * backup-prune"
+#(crontab -l; echo "$CRON_BACKUP_PRUNE") | crontab -
+
+
+# Storage
+
+sudo systemctl enable smartd --now
diff --git a/.local/bin/backup-prune b/.local/bin/backup-prune
new file mode 100755
index 0000000..78f5402
--- /dev/null
+++ b/.local/bin/backup-prune
@@ -0,0 +1,6 @@
+#!/bin/zsh
+
+source $HOME/.config/borg/.env-backup
+
+borg -v prune --keep-daily=7 --keep-weekly=4 --keep-monthly=12 ::
+borg -v compact ::
diff --git a/.local/bin/backup-run b/.local/bin/backup-run
new file mode 100755
index 0000000..ee2c013
--- /dev/null
+++ b/.local/bin/backup-run
@@ -0,0 +1,5 @@
+#!/bin/zsh
+
+source $HOME/.config/borg/.env-backup
+
+borg -v create ::$(date "+%Y%m%d_%H%M%S") "${BACKUP_PATH}"
diff --git a/.local/bin/shutdown-run b/.local/bin/shutdown-run
new file mode 100755
index 0000000..4820dbc
--- /dev/null
+++ b/.local/bin/shutdown-run
@@ -0,0 +1,6 @@
+#!/bin/zsh
+
+update
+backup-run
+backup-prune
+sudo shutdown -h
diff --git a/.local/bin/update b/.local/bin/update
index ee6f67d..c0c337c 100755
--- a/.local/bin/update
+++ b/.local/bin/update
@@ -23,5 +23,6 @@ docker_compose_project_paths = set(docker_compose_project_paths)
for path in docker_compose_project_paths:
subprocess.run(["docker", "compose", "down"], cwd=path)
+ subprocess.run(["docker", "compose", "build"], cwd=path)
subprocess.run(["docker", "compose", "pull"], cwd=path)
subprocess.run(["docker", "compose", "up", "-d"], cwd=path)
diff --git a/.zshrc b/.zshrc
index abbee52..3df12f8 100644
--- a/.zshrc
+++ b/.zshrc
@@ -1,7 +1,13 @@
+export ZSH="$HOME/.config/zsh/ohmyzsh"
+
CASE_SENSITIVE="false"
HYPHEN_INSENSITIVE="true"
HIST_STAMPS="dd.mm.yyyy"
+plugins=(git gitfast)
+ZSH_THEME=robbyrussell
+source $ZSH/oh-my-zsh.sh
+
export EDITOR=nvim
alias vim=$EDITOR
diff --git a/Applications/NextCloud/.env.example b/Applications/NextCloud/.env.example
index 52ae080..462e346 100644
--- a/Applications/NextCloud/.env.example
+++ b/Applications/NextCloud/.env.example
@@ -5,7 +5,9 @@ DB_NAME=nextcloud
DB_USER=nextcloud
DB_PASSWORD=nextcloud
-EXTERNAL_STORAGE_PATH_HOST=/media/nextcloud
+EXTERNAL_STORAGE_PATH_HOST=/media/nextcloud/NextCloud
EXTERNAL_STORAGE_PATH_CONTAINER=/media/nextcloud
-EXTERNAL_STORAGE_PARTITION=/dev/X
-EXTERNAL_STORAGE_FS_TYPE=fat
+
+EXTERNAL_STORAGE_MOUNT_PATH=/media/nextcloud
+EXTERNAL_STORAGE_MOUNT_PARTITION=/dev/sdXY
+EXTERNAL_STORAGE_MOUNT_FS_TYPE=fat
diff --git a/Applications/NextCloud/bin/fstab b/Applications/NextCloud/bin/fstab
index a804da2..fe47b94 100644
--- a/Applications/NextCloud/bin/fstab
+++ b/Applications/NextCloud/bin/fstab
@@ -2,11 +2,11 @@
source .env
-if grep -q "${EXTERNAL_STORAGE_PATH_HOST}"; then
+if grep -q "${EXTERNAL_STORAGE_MOUNT_PATH}"; then
echo "Already mounted."
exit
fi
-echo "${EXTERNAL_STORAGE_PARTITION} ${EXTERNAL_STORAGE_PATH_HOST} ${EXTERNAL_STORAGE_FS_TYPE} rw 0 1" >> "/etc/fstab"
-mkdir -p "${EXTERNAL_STORAGE_PATH_HOST}"
-mount -a -v
+echo "${EXTERNAL_STORAGE_MOUNT_PARTITION} ${EXTERNAL_STORAGE_MOUNT_PATH} ${EXTERNAL_STORAGE_MOUNT_FS_TYPE} auto,nofail,rw,user 0 0" >> "/etc/fstab"
+mkdir -p "${EXTERNAL_STORAGE_MOUNT_PATH}"
+mount -v "${EXTERNAL_STORAGE_MOUNT_PATH}"
diff --git a/Applications/NextCloud/docker-compose.yml b/Applications/NextCloud/docker-compose.yml
index c5af0b4..91f9df7 100644
--- a/Applications/NextCloud/docker-compose.yml
+++ b/Applications/NextCloud/docker-compose.yml
@@ -39,3 +39,4 @@ networks:
internal:
traefik:
name: "${TRAEFIK_NETWORK}"
+ external: true