From 9b62262c51e6f6d99f4b84b97d0bf2fd7376279f Mon Sep 17 00:00:00 2001 From: Tanmoy Sarkar <57363826+tanmoysrt@users.noreply.github.com> Date: Sun, 4 Feb 2024 19:59:03 +0530 Subject: [PATCH] feat: added functionality to measure size of volume --- README.MD | 7 +++++++ volume_toolkit | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.MD b/README.MD index c379616..1cd45a5 100644 --- a/README.MD +++ b/README.MD @@ -45,3 +45,10 @@ ```bash docker run --rm -v :/data -v /path/to/backup:/app ghcr.io/swiftwave-org/volume-toolkit import ``` +3. Measure the size of a persistent volume + + a. Run the following command + ```bash + docker run --rm -v :/data -v /path/to/backup:/app volume-toolkit size + ``` + b. The size of the persistent volume will be written in `/path/to/backup/size.txt` file in bytes format. \ No newline at end of file diff --git a/volume_toolkit b/volume_toolkit index ea8b644..c73fcf5 100644 --- a/volume_toolkit +++ b/volume_toolkit @@ -11,7 +11,11 @@ elif [ "$1" == "import" ]; then echo "dump.tar.gz not found" exit 1 fi +elif [ "$1" == "size" ]; then + size=$(du -sb /data | awk '{print $1}') + printf "%s" "$size" > /app/size.txt + exit 0 else - echo "Usage: volume_export.sh [export|import]" + echo "Usage: [export|import|size]" exit 1 fi \ No newline at end of file