From 3a541f7564ae4d5b78c155525d7b86c480713bd0 Mon Sep 17 00:00:00 2001 From: q Date: Tue, 25 Feb 2025 14:28:59 +0200 Subject: [PATCH] try with extra RAM --- files/archive-subfolders | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/files/archive-subfolders b/files/archive-subfolders index ab034da..918b362 100755 --- a/files/archive-subfolders +++ b/files/archive-subfolders @@ -1,6 +1,6 @@ #!/bin/bash -VERSION="20250214" +VERSION="20250225" function helpexit() { BS=$( basename "$0" ) @@ -13,6 +13,7 @@ function helpexit() { echo " --nl Do not store a separate file list." echo " --rm Remove source folders after archival." echo " --split SIZE Split archive to SIZE. ex. 500G" + echo " --chunk SIZE Buffer data in RAM to reduce simultaneous read/write. default: $CHUNKSIZE" echo " folder name: If given, archive only the named folder(s)." echo " If not, for loop over all folders in the current directory." @@ -76,6 +77,7 @@ REMOVE=0 KEEP_LIST=1 YES=0 SPLIT="" +CHUNKSIZE=100M for ((i=1; i<=${#@}; i++)) { [[ "${!i}" = "-h" ]] && helpexit [[ "${!i}" = "--help" ]] && helpexit @@ -85,6 +87,7 @@ for ((i=1; i<=${#@}; i++)) { [[ "${!i}" = "--nl" ]] && { KEEP_LIST=0; continue; } [[ "${!i}" = "--rm" ]] && { REMOVE=1; continue; } [[ "${!i}" = "--split" ]] && { i=$(( i + 1 )); SPLIT="${!i}"; continue; } + [[ "${!i}" = "--chunk" ]] && { i=$(( i + 1 )); CHUNKSIZE="${!i}"; continue; } [[ "${!i}" = "-"* ]] && helpexit FOLDERS+=( "${!i%/}" ) DEPTH=0 @@ -100,6 +103,13 @@ if [[ -n "$SPLIT" ]]; then exit 1 fi fi +if [[ "$CHUNKSIZE" =~ ^[0-9]+$ ]] || [[ "$CHUNKSIZE" =~ ^[0-9]+[KMGTPEZ]$ ]] || [[ "$CHUNKSIZE" =~ ^[0-9]+[KMGTPEZ]B$ ]]; then + true +else + echo "Cannot parse: $CHUNKSIZE. use ex. 256M. valid extension K M G T P E Z" + exit 1 +fi +CHUNKCMD="| dd obs=$CHUNKSIZE status=none " if tar --version | grep -q GNU; then SORTFILES="--sort=name" fi @@ -134,7 +144,7 @@ for d in "${REALFOLDERS[@]}"; do fi printf "\n" eval "tar cvv $SORTFILES --index-file=\"$d.${SUFFIX}.lst\" \"$d\" | \ - pv -s \"$SIZE\" $COMPRESSCMD $STORECMD" && { + pv -s \"$SIZE\" $COMPRESSCMD $CHUNKCMD $STORECMD" && { # tar exists okay NEWEST="$( awk '{ print $4 " " $5 }' "$d.${SUFFIX}.lst" | sort | tail -n 1 )" if [[ -n "$SPLIT" ]]; then