#!/bin/sh # Configuration BASE_DIR="/var/backups/backup_s3_example.net-upload" MY_CONFIG="/root/.s3cfg" BUCKET_NAME="$1" # Exemple de fichier de configuration s3cfg (version 1.0.0) # [default] # access_key = ABCDEFGHIJKLMNOPQRST # secret_key = KVwKO+9fea9jfazeafePfjaeafpagefiaea+FAEq # gpg_passphrase = TOTO # bucket_location = US # cloudfront_host = cloudfront.amazonaws.com # cloudfront_resource = /2010-07-15/distribution # default_mime_type = binary/octet-stream # delete_removed = False # dry_run = False # encoding = UTF-8 # encrypt = False # follow_symlinks = False # force = False # get_continue = False # gpg_command = /usr/bin/gpg # gpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s # gpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s # guess_mime_type = True # host_base = s3.amazonaws.com # host_bucket = %(bucket)s.s3.amazonaws.com # human_readable_sizes = False # list_md5 = False # log_target_prefix = # preserve_attrs = True # progress_meter = True # proxy_host = # proxy_port = 0 # recursive = False # recv_chunk = 4096 # reduced_redundancy = False # send_chunk = 4096 # simpledb_host = sdb.amazonaws.com # skip_existing = False # socket_timeout = 10 # urlencoding_mode = normal # use_https = True # verbosity = WARNING # Diminution de la priorité du script renice -n 20 $$ >/dev/null 2>&1 # Vérifications initiales if [ ! -d "$BASE_DIR" ]; then echo "ERREUR : répertoire de sauvegarde inexistant : $BASE_DIR ." >&2 exit 1 fi if [ "$BUCKET_NAME" = "" ]; then echo "ERREUR : aucun nom de seau fourni." >&2 exit 1 fi # Lancement de la synchronisation s3cmd -c "$MY_CONFIG" sync "s3://$BUCKET_NAME/" "$BASE_DIR/"