Skip to content

Instantly share code, notes, and snippets.

@tcocca
Forked from karussell/backup.sh
Created November 29, 2013 05:37

Revisions

  1. Peter created this gist Jul 10, 2011.
    19 changes: 19 additions & 0 deletions backup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    # TO_FOLDER=/something
    # FROM=/your-es-installation

    DATE=`date +%Y-%m-%d_%H-%M`
    TO=$TO_FOLDER/$DATE/
    echo "rsync from $FROM to $TO"
    # the first times rsync can take a bit long - do not disable flusing
    rsync -a $FROM $TO

    # now disable flushing and do one manual flushing
    $SCRIPTS/es-flush-disable.sh true
    $SCRIPTS/es-flush.sh
    # ... and sync again
    rsync -a $FROM $TO

    $SCRIPTS/es-flush-disable.sh false

    # now remove too old backups
    rm -rf `find $TO_FOLDER -maxdepth 1 -mtime +7` &> /dev/null
    7 changes: 7 additions & 0 deletions es-flush-disable.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    # true or false
    DISABLE=$1
    curl -XPUT 'localhost:9200/_settings' -d '{
    "index" : {
    "translog.disable_flush" : "'$DISABLE'"
    }
    }'
    1 change: 1 addition & 0 deletions es-flush.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    curl -XPOST 'localhost:9200/_flush'
    1 change: 1 addition & 0 deletions print-settings.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    curl -XGET 'localhost:9200/_settings?pretty=true'