Skip to content

Instantly share code, notes, and snippets.

@vanics
Forked from caraboides/backup-mongodb-to-s3.sh
Created June 18, 2018 00:20
Show Gist options
  • Save vanics/6ed7db351bfe3b1f4cdec5d4752c720e to your computer and use it in GitHub Desktop.
Save vanics/6ed7db351bfe3b1f4cdec5d4752c720e to your computer and use it in GitHub Desktop.

Revisions

  1. @caraboides caraboides revised this gist Jan 22, 2017. No changes.
  2. @caraboides caraboides renamed this gist Jan 22, 2017. 1 changed file with 1 addition and 0 deletions.
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    #!/bin/sh
    set -e
    HOST=localhost
    DB=test-entd-products
  3. @caraboides caraboides renamed this gist Jan 22, 2017. 1 changed file with 0 additions and 0 deletions.
  4. @caraboides caraboides renamed this gist Jan 22, 2017. 1 changed file with 0 additions and 0 deletions.
  5. @caraboides caraboides created this gist Jan 22, 2017.
    15 changes: 15 additions & 0 deletions Back Mongo To S3 with Streaming
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    set -e
    HOST=localhost
    DB=test-entd-products
    COL=asimproducts

    S3PATH="s3://mongodb-backups-test1-entd/$DB/$COL/"
    S3BACKUP=$S3PATH`date +"%Y%m%d_%H%M%S"`.dump.gz
    S3LATEST=$S3PATH"latest".dump.gz
    /usr/bin/aws s3 mb $S3PATH
    /usr/bin/mongodump -h $HOST -d $DB -c $COL -o - | gzip -9 | aws s3 cp - $S3BACKUP
    aws s3 cp $S3BACKUP $S3LATEST

    # Restore
    echo -n "Restore: "
    echo -n "aws s3 cp $S3LATEST - |gzip -d | mongorestore --host $HOST --db $DB -c $COL - "