Create archive and hard link to latest file

This commit is contained in:
Jeremy Gardais 2021-04-12 16:18:34 +02:00
parent 49d0740b7e
commit b8d3c9554f
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 14 additions and 1 deletions

View File

@ -13,6 +13,7 @@ readonly NBARGS="${#}"
[ -z "${DEBUG}" ] && DEBUG=1
readonly DEFAULT_LOCAL_BKP_DIR="/etc/proxmox.pve/backup"
readonly TODAY_VAR=$(date +%Y%m%d)
## Colors
readonly PURPLE='\033[1;35m'
@ -96,12 +97,24 @@ main() { # {{{
## Define all vars
define_vars
## Verify if the destination directory is absent {{{
## Verify if the local destination directory is absent {{{
### AND create it
is_directory_absent "${local_bkp_dir}" \
&& mkdir -p -- ${local_bkp_dir}
## }}}
## Create an archive of /etc/pve to $local_bkp_dir {{{
### OR exit with error code 2 if it fails
tar czf "${local_bkp_dir}/pve.${TODAY_VAR}.tar.gz" -C /etc/ pve/ \
|| exit 2
## }}}
## Create an hard link to pve.latest.tar.gz {{{
### OR exit with error code 3 if it fails
ln -- "${local_bkp_dir}/pve.${TODAY_VAR}.tar.gz" "${local_bkp_dir}/pve.latest.tar.gz" \
|| exit 3
## }}}
}
# }}}