From 28378ec31f20bf54cce017d8d465991209adb94c Mon Sep 17 00:00:00 2001 From: Pablo Sarria Date: Wed, 9 Jan 2019 18:38:05 +0100 Subject: [PATCH] =?UTF-8?q?a=C3=B1ado=20soporte=20para=20argumento=20de=20?= =?UTF-8?q?dias=20a=20borrar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zonebackuptofile.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/zonebackuptofile.sh b/zonebackuptofile.sh index 234cac2..09bf391 100755 --- a/zonebackuptofile.sh +++ b/zonebackuptofile.sh @@ -2,16 +2,19 @@ usage() { - echo "Usage: $0 -z UUID" >&2 + echo "Usage: $0 -z UUID -d days" >&2 exit 1 } -while getopts "z:" opt; +while getopts "z:d:" opt; do case "$opt" in z) UUID=$OPTARG ;; + d) + DAYS=$OPTARG + ;; *) usage ;; @@ -24,6 +27,10 @@ if [ -z "${UUID}" ]; then usage fi +if [ -z "${DAYS}" ]; then + usage +fi + BRAND=`/usr/sbin/vmadm get $UUID | json brand | tr -d '\n'` RUTADESTINO="/zones/tools/mounts" @@ -47,8 +54,8 @@ if [ $? != 0 ]; then exit fi -# mantenemos los backups de los ultimos dos dias -find $RUTADESTINO/$UUID -type f -mtime +3 -delete +# mantain backups of the last N days +find $RUTADESTINO/$UUID -type f -mtime +$DAYS -delete snapshot() {