From b8d3c9554f079d962c88570b08ef99a253a520ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 12 Apr 2021 16:18:34 +0200 Subject: [PATCH] Create archive and hard link to latest file --- proxmox/backup.pve.content.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/proxmox/backup.pve.content.sh b/proxmox/backup.pve.content.sh index 7a73806..337539e 100755 --- a/proxmox/backup.pve.content.sh +++ b/proxmox/backup.pve.content.sh @@ -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 + ## }}} + + } # }}}