From 6b6b093de673cf7a67102e318246c91630a8b27d Mon Sep 17 00:00:00 2001 From: Buleandra Cristian Date: Wed, 5 Nov 2025 01:44:16 +0100 Subject: [PATCH 1/2] Enhance backup script with pigz support Added support for parallel compression and decompression using pigz if available. --- migrate.sh | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/migrate.sh b/migrate.sh index 457b848..62d548a 100644 --- a/migrate.sh +++ b/migrate.sh @@ -84,8 +84,17 @@ if [ ! -f "$backupFileName" ]; then echo "🚸 Docker not stopped, continuing with the backup" fi + # Choose compressor + if command -v pigz >/dev/null 2>&1; then + echo "✅ Using pigz for parallel gzip" + compressor="pigz -p$(nproc)" + else + echo "â„šī¸ pigz not found, using gzip" + compressor="gzip" + fi + # shellcheck disable=SC2086 - if ! tar --exclude='*.sock' -Pczf $backupFileName -C / $backupSourceDir $HOME/.ssh/authorized_keys $volumePaths; then + if ! tar --exclude='*.sock' -I "$compressor" -Pcf "$backupFileName" -C / $backupSourceDir $HOME/.ssh/authorized_keys $volumePaths; then echo "❌ Backup file creation failed" exit 1 fi @@ -157,7 +166,17 @@ remoteCommands=" cp ~/.ssh/authorized_keys ~/.ssh/authorized_keys_backup; echo '🚸 Extracting backup file...'; - if ! tar -Pxzf - -C /; then + # pick decompressor + if command -v pigz >/dev/null 2>&1; then + echo '✅ Using pigz for parallel decompression'; + decompressor="pigz -dc" + else + echo 'â„šī¸ pigz not found, using gzip'; + decompressor="gzip -dc" + fi + + # run extraction + if ! $decompressor | tar -Px -C /; then echo '❌ Backup file extraction failed'; exit 1; fi From ad90a9bdf0c7f9f94fdbf6147a1cbb007332e613 Mon Sep 17 00:00:00 2001 From: Buleandra Cristian Date: Sat, 8 Nov 2025 11:36:20 +0100 Subject: [PATCH 2/2] Fix pigz decompression, and suppress file-changed warnings while compressing --- migrate.sh | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/migrate.sh b/migrate.sh index 62d548a..aab3819 100644 --- a/migrate.sh +++ b/migrate.sh @@ -94,11 +94,14 @@ if [ ! -f "$backupFileName" ]; then fi # shellcheck disable=SC2086 - if ! tar --exclude='*.sock' -I "$compressor" -Pcf "$backupFileName" -C / $backupSourceDir $HOME/.ssh/authorized_keys $volumePaths; then + tar --exclude='*.sock' --warning=no-file-changed -I "$compressor" -Pcf "$backupFileName" \ + -C / $backupSourceDir $HOME/.ssh/authorized_keys $volumePaths + rc=$? + if [ $rc -gt 1 ]; then echo "❌ Backup file creation failed" exit 1 fi - echo "✅ Backup file created" + echo "✅ Backup file created (with change warnings suppressed)" else echo "🚸 Backup file already exists, skipping creation" fi @@ -165,22 +168,20 @@ remoteCommands=" echo '🚸 Saving existing authorized keys...'; cp ~/.ssh/authorized_keys ~/.ssh/authorized_keys_backup; - echo '🚸 Extracting backup file...'; - # pick decompressor + echo '🚸 Extracting backup file...' if command -v pigz >/dev/null 2>&1; then - echo '✅ Using pigz for parallel decompression'; - decompressor="pigz -dc" + echo '✅ Using pigz for parallel decompression' + if ! tar -I pigz -Pxf - -C /; then + echo '❌ Backup file extraction failed' + exit 1 + fi else - echo 'â„šī¸ pigz not found, using gzip'; - decompressor="gzip -dc" - fi - - # run extraction - if ! $decompressor | tar -Px -C /; then - echo '❌ Backup file extraction failed'; - exit 1; + if ! tar -Pzxf - -C /; then + echo '❌ Backup file extraction failed' + exit 1 + fi fi - echo '✅ Backup file extracted'; + echo '✅ Backup file extracted' echo '🚸 Merging authorized keys...'; cat ~/.ssh/authorized_keys_backup ~/.ssh/authorized_keys | sort | uniq > ~/.ssh/authorized_keys_temp;