Compare commits
3 commits
a6561ba279
...
e7d024f68a
Author | SHA1 | Date | |
---|---|---|---|
e7d024f68a | |||
12683853e5 | |||
5e5e489d85 |
3 changed files with 72 additions and 0 deletions
41
bash/.bashrc
41
bash/.bashrc
|
@ -124,3 +124,44 @@ export QT_IM_MODULE=fcitx
|
|||
export SDL_IM_MODULE=fcitx
|
||||
export WLR_XWAYLAND=$HOME/.local/bin/Xwayland-noshm
|
||||
$MACHINE_START_SWAY && [[ -z "$DISPLAY" && $(tty) == /dev/tty1 ]] && exec sway
|
||||
|
||||
# Miscellaneous utilities
|
||||
function clamp_filename() {
|
||||
[[ -z "$1" ]] && return 1
|
||||
|
||||
local len="$1"
|
||||
|
||||
for file in *; do
|
||||
local filename_len=$(echo "$file" | wc -c)
|
||||
|
||||
if [ $filename_len -gt $len ]; then
|
||||
local extension="${file##*.}"
|
||||
local filename="${filename%.*}"
|
||||
if [ ${#extension} -gt 5 ]; then
|
||||
filename="$file"
|
||||
extension=""
|
||||
fi
|
||||
local clamped_filename="$(echo "$file" | cut -c1-$((len - ${#extension})) | iconv -f utf8 -t utf8 -c -)"
|
||||
if [ ${#extension} -gt 0 ]; then
|
||||
clamped_filename="$clamped_filename.$extension"
|
||||
fi
|
||||
echo "File '$PWD/$file' clamped to '$PWD/$clamped_filename'"
|
||||
mv "$file" "$clamped_filename"
|
||||
file="$clamped_filename"
|
||||
fi
|
||||
|
||||
if [ -d "$file" ]; then
|
||||
pushd "$file" > /dev/null
|
||||
clamp_filename "$1"
|
||||
popd > /dev/null
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function open_nas_decrypt() {
|
||||
gocryptfs -passfile /dev/stdin "$MACHINE_NAS_CIPHER_PATH" "$MACHINE_NAS_DECRYPT_PATH" <<< "$(pass gocrypt show "$MACHINE_NAS_CIPHER_PASS")"
|
||||
}
|
||||
|
||||
function close_nas_decrypt() {
|
||||
fusermount -u "$MACHINE_NAS_DECRYPT_PATH"
|
||||
}
|
||||
|
|
24
restic-backup/.local/bin/restic-backup
Executable file
24
restic-backup/.local/bin/restic-backup
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
source ~/.config/restic-backup/config.sh
|
||||
|
||||
cleanup() {
|
||||
pass gocrypt close || true > /dev/null 2>&1
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
pass gocrypt close > /dev/null 2>&1 || true
|
||||
PASS_GOCRYPT_CLOSE_TIMEOUT=2147483648 pass gocrypt open
|
||||
|
||||
for dir in ${RESTIC_BACKUP_SUBVOL_PATHS[@]}; do
|
||||
parent="$(dirname $dir)"
|
||||
snap="$parent/$(basename $dir)-restic"
|
||||
echo "snap = $snap"
|
||||
sudo btrfs subvol delete "$snap" > /dev/null 2>&1 || true
|
||||
sudo btrfs subvol snap "$dir" "$snap"
|
||||
restic-wrapper --verbose backup "$snap"
|
||||
sudo btrfs subvol delete "$snap" || true
|
||||
done
|
7
restic-backup/.local/bin/restic-wrapper
Executable file
7
restic-backup/.local/bin/restic-wrapper
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
source ~/.config/restic-backup/config.sh
|
||||
pass gocrypt open || true
|
||||
sudo restic --password-file /dev/stdin -r "$RESTIC_BACKUP_REPO" $@ <<< $(pass show "$RESTIC_BACKUP_PASS")
|
Loading…
Add table
Reference in a new issue