now supports secondary backup
This commit is contained in:
parent
2fff3ce2a2
commit
0db312e8a0
22
update
22
update
@ -20,14 +20,16 @@ if [ ! -d $BACKUP_LOCATION ]; then
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $SECONDARY_BACKUP_LOCATION ]; then
|
if [ $SECONDARY_BACKUP_LOCATION ]; then
|
||||||
echo -e "${IYELLOW}Secondary Backup location doesn't exist${NO_COLOR}"
|
if [ ! -d $SECONDARY_BACKUP_LOCATION ]; then
|
||||||
read -p "Do you want to create the path and continue? [y/N]" input
|
echo -e "${IYELLOW}Secondary Backup location doesn't exist${NO_COLOR}"
|
||||||
case $input in
|
read -p "Do you want to create the path and continue? [y/N]" input
|
||||||
[Yy]) mkdir --parents "$SECONDARY_BACKUP_LOCATION" ;;
|
case $input in
|
||||||
[Nn]) exit 0;;
|
[Yy]) mkdir --parents "$SECONDARY_BACKUP_LOCATION" ;;
|
||||||
* ) exit 0 ;;
|
[Nn]) exit 0;;
|
||||||
esac
|
* ) exit 0 ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
trap interrupt_function INT
|
trap interrupt_function INT
|
||||||
@ -81,6 +83,7 @@ before_backup() {
|
|||||||
|
|
||||||
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
|
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"
|
mv "$TMP"/before-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"
|
||||||
|
[[ $SECONDARY_BACKUP_LOCATION ]] && mv "$TMP"/before-backup_"$DATE".tar.zst.new "$SECONDARY_BACKUP_LOCATION"
|
||||||
|
|
||||||
sudo rm --force /var/lib/pacman/db.lck
|
sudo rm --force /var/lib/pacman/db.lck
|
||||||
}
|
}
|
||||||
@ -91,11 +94,14 @@ after_backup() {
|
|||||||
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" > /dev/null 2>&1
|
||||||
|
|
||||||
mv "$TMP"/after-backup_"$DATE".tar.zst.new "$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
|
delete_oldest_backup after-backup
|
||||||
mv "$BACKUP_LOCATION"/after-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"/after-backup_"$DATE".tar.zst
|
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
|
||||||
|
|
||||||
delete_oldest_backup before-backup
|
delete_oldest_backup before-backup
|
||||||
mv "$BACKUP_LOCATION"/before-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"/before-backup_"$DATE".tar.zst
|
mv "$BACKUP_LOCATION"/before-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"/before-backup_"$DATE".tar.zst
|
||||||
|
[[ $SECONDARY_BACKUP_LOCATION ]] && mv "$SECONDARY_BACKUP_LOCATION"/before-backup_"$DATE".tar.zst.new "$SECONDARY_BACKUP_LOCATION"/before-backup_"$DATE".tar.zst
|
||||||
|
|
||||||
rm --recursive --force "$TMP"
|
rm --recursive --force "$TMP"
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
BACKUP_LOCATION=~/
|
BACKUP_LOCATION=~/
|
||||||
|
|
||||||
# optional secondary backup loaction
|
# optional secondary backup loaction
|
||||||
SECONDARY_BACKUP_LOCATION=/dev/null
|
#SECONDARY_BACKUP_LOCATION=~/
|
||||||
|
|
||||||
# use this pacman-wrapper
|
# use this pacman-wrapper
|
||||||
PACMAN_WRAPPER=yay
|
PACMAN_WRAPPER=yay
|
||||||
|
Loading…
x
Reference in New Issue
Block a user