diff --git a/backup_and_restore/scaleway/list-fichier-bucket.sh b/backup_and_restore/scaleway/list-fichier-bucket.sh deleted file mode 100644 index f170fbe..0000000 --- a/backup_and_restore/scaleway/list-fichier-bucket.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -# This script lists objects stored in the Glacier storage class within an S3 bucket. -# It optionally filters the list based on a specified directory within the bucket. -# The output is saved to a text file with a sanitized name based on the bucket and directory. - -# Example usage: -# ./list-glacier-objects.sh my-bucket my-directory -# (Lists objects in the 'my-directory' directory within the 'my-bucket' bucket) -# ./list-glacier-objects.sh my-bucket -# (Lists all objects in the 'my-bucket' bucket) - -# Vérification du nombre d'arguments -if [[ $# -lt 1 || $# -gt 2 ]]; then - echo "Utilisation: $0 [nom_du_répertoire]" - exit 1 -fi - -# Récupération des arguments -BUCKET="$1" -DIRECTORY="$2" - -# Fonction pour "nettoyer" les noms pour le fichier de sortie -sanitize_name() { - echo "$1" | tr -dc '[:alnum:]-_.' -} - -# Construction du nom de fichier de sortie -SANITIZED_BUCKET=$(sanitize_name "$BUCKET") -if [[ -n "$DIRECTORY" ]]; then - SANITIZED_DIRECTORY=$(sanitize_name "$DIRECTORY") - OUTPUT_FILE="${SANITIZED_BUCKET}_${SANITIZED_DIRECTORY}_glacier-restore.txt" -else - OUTPUT_FILE="${SANITIZED_BUCKET}_glacier-restore.txt" -fi - -# Construction de la commande AWS CLI -COMMAND="aws s3api list-objects-v2 --bucket $BUCKET --query \"Contents[?StorageClass=='GLACIER']\"" - -# Ajout du préfixe si un répertoire est spécifié -if [[ -n "$DIRECTORY" ]]; then - COMMAND+=" --prefix $DIRECTORY" -fi - -# Finalisation de la commande avec la sortie formatée -COMMAND+=" --output text | awk '{print \$2}' > $OUTPUT_FILE" - -# Exécution de la commande -eval $COMMAND - -# Message de confirmation -echo "Liste des objets Glacier enregistrée dans $OUTPUT_FILE" diff --git a/backup_and_restore/scaleway/list-file-bucket.sh b/backup_and_restore/scaleway/list-file-bucket.sh new file mode 100644 index 0000000..e5a8cea --- /dev/null +++ b/backup_and_restore/scaleway/list-file-bucket.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# This script lists objects stored in the Glacier storage class within an S3 bucket. +# It optionally filters the list based on a specified directory within the bucket. +# The output is saved to a text file with a sanitized name based on the bucket and directory. + +# Example usage: +# ./list-glacier-objects.sh my-bucket my-directory  +# (Lists objects in the 'my-directory' directory within the 'my-bucket' bucket) +# ./list-glacier-objects.sh my-bucket  +# (Lists all objects in the 'my-bucket' bucket) + +# Check the number of arguments +if [[ $# -lt 1 || $# -gt 2 ]]; then +    echo "Usage: $0 [directory_name]" +    exit 1 +fi + +# Retrieve the arguments +BUCKET="$1" +DIRECTORY="$2" + +# Function to "sanitize" names for the output file +sanitize_name() { +    echo "$1" | tr -dc '[:alnum:]-_.'  +} + +# Construct the output file name +SANITIZED_BUCKET=$(sanitize_name "$BUCKET") +if [[ -n "$DIRECTORY" ]]; then +    SANITIZED_DIRECTORY=$(sanitize_name "$DIRECTORY") +    OUTPUT_FILE="${SANITIZED_BUCKET}_${SANITIZED_DIRECTORY}_glacier-restore.txt" +else +    OUTPUT_FILE="${SANITIZED_BUCKET}_glacier-restore.txt" +fi + +# Construct the AWS CLI command +COMMAND="aws s3api list-objects-v2 --bucket $BUCKET --query \"Contents[?StorageClass=='GLACIER']\"" + +# Add the prefix if a directory is specified +if [[ -n "$DIRECTORY" ]]; then +    COMMAND+=" --prefix $DIRECTORY" +fi + +# Finalize the command with formatted output +COMMAND+=" --output text | awk '{print \$2}' > $OUTPUT_FILE" + +# Execute the command +eval $COMMAND + +# Confirmation message +echo "List of Glacier objects saved in $OUTPUT_FILE" diff --git a/backup_and_restore/scaleway/chamgement_class_standard.sh b/backup_and_restore/scaleway/update_class_standard.sh similarity index 100% rename from backup_and_restore/scaleway/chamgement_class_standard.sh rename to backup_and_restore/scaleway/update_class_standard.sh