Use argument list as array items

This commit is contained in:
Jeffrey Serio 2025-02-26 21:54:23 -06:00
parent 7ceb3c4440
commit 68fa93f34f

View File

@ -2,19 +2,21 @@
set -euo pipefail
if [ "$#" -eq 0 ]; then
echo "Enter one or more Podman volume names."
exit 1
fi
BACKUP_DIR="${HOME}/podman_volume_backups"
DATE=$(date '+%Y-%m-%d_%H%M%S')
volumes=(
"grafana-storage"
"semaphore_semaphore-mysql"
)
volumes=("$@")
for vol in "${volumes[@]}"; do
podman volume export "$vol" --output "${BACKUP_DIR}/${vol}-${DATE}.tar"
gzip "${BACKUP_DIR}/${vol}-${DATE}.tar"
done
find "$BACKUP_DIR" -maxdepth 1 -mtime +7 -type f -delete
find "$BACKUP_DIR" -maxdepth 1 -mtime +3 -type f -delete
exit 0