mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-18 19:00:15 +00:00
Updates and improvements
install.sh installScripts function: update script not being copied over to /opt therefore update funcion was probably broken. changed script to copy all .sh scripts from .pivpn/scripts directory. Issue #871: fix backup script I was probably very drunk when i first wrote this backup script. fixed it, now works with new code refactoring, loads vars from setupVars Added backup for wireguard Moved script to global pivpnscripts. Added backup script to bash-completion Added backup script to pivpn script update.sh Commented the update from master branch to avoid users trying to update test from master. Updated LatestChages.md
This commit is contained in:
parent
412c8e83ac
commit
8096af7ad0
1 changed files with 52 additions and 0 deletions
52
scripts/backup.sh
Executable file
52
scripts/backup.sh
Executable file
|
@ -0,0 +1,52 @@
|
|||
#!/bin/bash
|
||||
# shellcheck disable=SC1091
|
||||
source /etc/pivpn/setupVars.conf
|
||||
# shellcheck disable=SC1090
|
||||
backupdir=pivpnbackup
|
||||
date=$(date +%Y%m%d-%H%M%S)
|
||||
|
||||
checkbackupdir(){
|
||||
|
||||
if [[ ! -d $install_home/$backupdir ]]; then
|
||||
mkdir -p "$install_home"/"$backupdir"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
backup_openvpn(){
|
||||
|
||||
openvpndir=/etc/openvpn
|
||||
ovpnsdir=${install_home}/ovpns
|
||||
checkbackupdir
|
||||
backupzip=$date-pivpnovpnbackup.tgz
|
||||
# shellcheck disable=SC2210
|
||||
tar czpf "$install_home"/"$backupdir"/"$backupzip" "$openvpndir" "$ovpnsdir" > /dev/null 2>&1
|
||||
echo -e "Backup crated to $install_home/$backupdir/$backupzip \nTo restore the backup, follow instructions at:\nhttps://github.com/pivpn/pivpn/wiki/FAQ#how-can-i-migrate-my-configs-to-another-pivpn-instance"
|
||||
|
||||
}
|
||||
|
||||
backup_wireguard(){
|
||||
|
||||
wireguarddir=/etc/wireguard
|
||||
configsdir=${install_home}/configs
|
||||
checkbackupdir
|
||||
backupzip=$date-pivpnwgbackup.tgz
|
||||
tar czpf "$install_home"/"$backupdir"/"$backupzip" "$wireguarddir" "$configsdir" > /dev/null 2>&1
|
||||
echo -e "Backup crated to $install_home/$backupdir/$backupzip \nTo restore the backup, follow instructions at:\nhttps://github.com/pivpn/pivpn/wiki/FAQ#how-can-i-migrate-my-configs-to-another-pivpn-instance"
|
||||
|
||||
}
|
||||
|
||||
if [[ ! $EUID -eq 0 ]];then
|
||||
if [[ $(dpkg-query -s sudo) ]];then
|
||||
export SUDO="sudo"
|
||||
else
|
||||
echo "::: Please install sudo or run this as root."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${VPN}" == "wireguard" ]]; then
|
||||
backup_wireguard
|
||||
else
|
||||
backup_openvpn
|
||||
fi
|
Loading…
Reference in a new issue