Skip to content

Instantly share code, notes, and snippets.

@lovellfelix
Created April 10, 2018 15:39
Show Gist options
  • Select an option

  • Save lovellfelix/efd233e08a77145fc5e3ddade81d29c8 to your computer and use it in GitHub Desktop.

Select an option

Save lovellfelix/efd233e08a77145fc5e3ddade81d29c8 to your computer and use it in GitHub Desktop.

Revisions

  1. lovellfelix created this gist Apr 10, 2018.
    23 changes: 23 additions & 0 deletions upload_to_glacier.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #!/bin/sh
    # variables for vault name, timestamp, and output file
    VAULT="sandbox-02"
    NOW=$(date +%s)
    IDFILE="archive-ids-${NOW}.json"

    # make sure we can write the output file
    touch $IDFILE || exit 1

    # upload all tar files in forbackup directory, writing
    # results to the output file
    #
    # the archive-description string in the filename prefixed
    # with the timestamp. this information may be of great
    # help when/if we later retrieve the file.
    for F in /home/myproject/forbackup/*.tar; do
    echo "# $F" >> $IDFILE
    aws glacier upload-archive \
    --vault-name "$VAULT" \
    --account-id - \
    --archive-description "${NOW}/$F" \
    --body "$F" >> $IDFILE
    done