fixed some stuff

This commit is contained in:
AustrianToast 2024-07-23 19:57:36 +02:00
parent b13189e7de
commit 6fce70ba3c
Signed by: AustrianToast
GPG Key ID: 378A29F999424B1C

21
update
View File

@ -1,6 +1,6 @@
#!/usr/bin/bash
VERSION="3.1"
VERSION="3.2"
IGREEN="\033[0;92m" # Intense Green
IYELLOW="\033[0;93m" # Intense Yellow
IRED='\033[0;91m' # Red
@ -11,10 +11,10 @@ DATE="$(date +"%Y-%m-%dT%H:%M:%S%:z")" # RFC 3339 date-time https://datatracker
trap interrupt_function INT
interrupt_function() {
echo "Interrupt has been detected"
echo -e "${IRED}\nInterrupt has been detected${NO_COLOR}"
if [ -f /var/lib/pacman/db.lck ]; then
echo -e "${IYELLOW}Trying to unlock the pacman db. Please enter your password.${NO_COLOR}"
su --command="rm --force /var/lib/pacman/db.lck" > /dev/null 2>&1
echo -e "${IRED}Trying to unlock the pacman db. Please enter your password.${NO_COLOR}"
su --command="rm --force /var/lib/pacman/db.lck"
fi
[[ -d $TMP ]] && rm --recursive --force "$TMP"
[[ -f "$BACKUP_LOCATION"/before-backup_"$DATE".tar.zst.new ]] && rm --force "$BACKUP_LOCATION"/before-backup_"$DATE".tar.zst.new
@ -99,9 +99,9 @@ before_backup() {
pacman --verbose --query > "$TMP"/before-backup_"$DATE"/pacman-before.txt
[[ -x /usr/bin/flatpak ]] && flatpak list --all --show-details > "$TMP"/before-backup_"$DATE"/flatpak-before.txt
tar --create --zstd --file "$TMP"/before-backup_"$DATE".tar.zst.new "$TMP"/before-backup_"$DATE" /var/lib/pacman/local > /dev/null 2>&1 # for some reason it needs the output suppresion
mv "$TMP"/before-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"
[[ $SECONDARY_BACKUP_LOCATION ]] && mv "$TMP"/before-backup_"$DATE".tar.zst.new "$SECONDARY_BACKUP_LOCATION"
tar --create --zstd --file "$TMP"/before-backup_"$DATE".tar.zst.new "$TMP"/before-backup_"$DATE" /var/lib/pacman/local
cp "$TMP"/before-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"
[[ $SECONDARY_BACKUP_LOCATION ]] && cp "$TMP"/before-backup_"$DATE".tar.zst.new "$SECONDARY_BACKUP_LOCATION"
unlock_pacman_db
}
@ -111,10 +111,11 @@ after_backup() {
pacman --verbose --query > "$TMP"/after-backup_"$DATE"/pacman-after.txt
[[ -x /usr/bin/flatpak ]] && flatpak list --all --show-details > "$TMP"/after-backup_"$DATE"/flatpak-after.txt
tar --create --zstd --file "$TMP"/after-backup_"$DATE".tar.zst.new "$TMP"/after-backup_"$DATE" > /dev/null 2>&1
tar --create --zstd --file "$TMP"/after-backup_"$DATE".tar.zst.new "$TMP"/after-backup_"$DATE"
cp "$TMP"/after-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"
[[ $SECONDARY_BACKUP_LOCATION ]] && cp "$TMP"/after-backup_"$DATE".tar.zst.new "$SECONDARY_BACKUP_LOCATION"
mv "$TMP"/after-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"
[[ $SECONDARY_BACKUP_LOCATION ]] && mv "$TMP"/before-backup_"$DATE".tar.zst.new "$SECONDARY_BACKUP_LOCATION"
delete_oldest_backup after-backup
mv "$BACKUP_LOCATION"/after-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"/after-backup_"$DATE".tar.zst
[[ $SECONDARY_BACKUP_LOCATION ]] && mv "$SECONDARY_BACKUP_LOCATION"/after-backup_"$DATE".tar.zst.new "$SECONDARY_BACKUP_LOCATION"/after-backup_"$DATE".tar.zst