Only backup WireGuard folder if it contains files

This commit is contained in:
Orazio 2025-03-12 08:38:21 +01:00
parent 258e800e42
commit e3e11f5d22
No known key found for this signature in database

View file

@ -3217,6 +3217,7 @@ confWireGuard() {
fi
if [[ -d /etc/wireguard ]]; then
if [[ -n "$(ls -A /etc/wireguard)" ]]; then
# Backup the wireguard folder
WIREGUARD_BACKUP="wireguard_$(date +%Y-%m-%d-%H%M%S).tar.gz"
echo "::: Backing up the wireguard folder to /etc/${WIREGUARD_BACKUP}"
@ -3224,6 +3225,7 @@ confWireGuard() {
umask 0077
${SUDO} tar -czf "/etc/${WIREGUARD_BACKUP}" /etc/wireguard &> /dev/null
umask "${CURRENT_UMASK}"
fi
if [[ -f /etc/wireguard/wg0.conf ]]; then
${SUDO} rm /etc/wireguard/wg0.conf