mirror of
https://github.com/pivpn/pivpn.git
synced 2025-05-10 18:04:10 +02:00
Only backup WireGuard folder if it contains files
This commit is contained in:
parent
258e800e42
commit
e3e11f5d22
1 changed files with 9 additions and 7 deletions
|
@ -3217,13 +3217,15 @@ confWireGuard() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d /etc/wireguard ]]; then
|
if [[ -d /etc/wireguard ]]; then
|
||||||
# Backup the wireguard folder
|
if [[ -n "$(ls -A /etc/wireguard)" ]]; then
|
||||||
WIREGUARD_BACKUP="wireguard_$(date +%Y-%m-%d-%H%M%S).tar.gz"
|
# Backup the wireguard folder
|
||||||
echo "::: Backing up the wireguard folder to /etc/${WIREGUARD_BACKUP}"
|
WIREGUARD_BACKUP="wireguard_$(date +%Y-%m-%d-%H%M%S).tar.gz"
|
||||||
CURRENT_UMASK="$(umask)"
|
echo "::: Backing up the wireguard folder to /etc/${WIREGUARD_BACKUP}"
|
||||||
umask 0077
|
CURRENT_UMASK="$(umask)"
|
||||||
${SUDO} tar -czf "/etc/${WIREGUARD_BACKUP}" /etc/wireguard &> /dev/null
|
umask 0077
|
||||||
umask "${CURRENT_UMASK}"
|
${SUDO} tar -czf "/etc/${WIREGUARD_BACKUP}" /etc/wireguard &> /dev/null
|
||||||
|
umask "${CURRENT_UMASK}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -f /etc/wireguard/wg0.conf ]]; then
|
if [[ -f /etc/wireguard/wg0.conf ]]; then
|
||||||
${SUDO} rm /etc/wireguard/wg0.conf
|
${SUDO} rm /etc/wireguard/wg0.conf
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue