Created
March 30, 2025 07:21
-
-
Save muhamad-ridwant-tech/c08906ee227b5f171e3784938aaf63af to your computer and use it in GitHub Desktop.
Hystax Accura - Clean up resources in the target cloud after a successful migration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### Hystax Accura - Clean up resources in the target cloud after a successful migration. | |
### https://support.hystax.com/portal/en/kb/articles/how-to-clean-up-resources-in-the-target-cloud-after-a-successful-migration | |
## Pastikan file "volume_ids.txt" sudah terisi list volume id. | |
VOLUME_FILE="volume_ids.txt" | |
if [[ ! -f "$VOLUME_FILE" ]]; then | |
echo "File $VOLUME_FILE tidak ditemukan!" | |
exit 1 | |
fi | |
# Loop setiap volume-ID dalam file | |
while read -r VOLUME_ID; do | |
if [[ -z "$VOLUME_ID" ]]; then | |
continue # Lewati baris kosong | |
fi | |
echo "==========================================" | |
echo "Processing volume: $VOLUME_ID" | |
# List snapshot | |
SNAP_NAME=$(rbd -p volumes_ssd snap ls volume-"$VOLUME_ID" | awk 'NR==2 {print $2}') | |
if [[ -z "$SNAP_NAME" ]]; then | |
echo "β Snapshot tidak ditemukan untuk volume-$VOLUME_ID, melewati..." | |
continue | |
fi | |
echo "β Snapshot ditemukan: $SNAP_NAME" | |
# Cari children | |
CHILDREN=$(rbd children volumes_ssd/volume-"$VOLUME_ID"@"$SNAP_NAME") | |
if [[ -z "$CHILDREN" ]]; then | |
echo "β Tidak ada children untuk snapshot $SNAP_NAME pada volume-$VOLUME_ID" | |
continue | |
fi | |
echo "π Children ditemukan: $CHILDREN" | |
# Loop melalui setiap child yang ditemukan | |
for CHILD in $CHILDREN; do | |
echo "β Mengecek dan flatten $CHILD..." | |
# Pastikan child ada sebelum melakukan flatten | |
CHECK_CHILD=$(rbd info "$CHILD" 2>/dev/null) | |
if [[ -z "$CHECK_CHILD" ]]; then | |
echo "β Child $CHILD tidak valid atau tidak ditemukan, melewati..." | |
continue | |
fi | |
# Jalankan flatten | |
rbd flatten "$CHILD" | |
if [[ $? -eq 0 ]]; then | |
echo "β Flatten $CHILD selesai." | |
else | |
echo "β Gagal melakukan flatten pada $CHILD." | |
fi | |
done | |
echo "β Processing volume-$VOLUME_ID selesai." | |
echo "==========================================" | |
done < "$VOLUME_FILE" | |
echo "π Semua volume telah diproses." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment