@@ -11,11 +11,23 @@ Elasticsearch snapshot in your S3 snapshot repository.
1111
1212Recommended setup for running as an app on Aptible:
1313
14- 1 . Create an S3 bucket for your logs in the same region as your Elasticsearch
14+ 1 . Make sure your Elasticsearch instance has the
15+ [ cloud-aws plugin] ( https://github.com/elastic/elasticsearch-cloud-aws )
16+ installed. You can check that it's installed by running:
17+
18+ ```
19+ grep cloud-aws <(curl ${ELASTICSEARCH_URL}/_cat/plugins 2>/dev/null)
20+ ```
21+
22+ If that command prints nothing, you need to [find the appropriate plugin
23+ version for your server](https://github.com/elastic/elasticsearch-cloud-aws#aws-cloud-plugin-for-elasticsearch)
24+ and install it.
25+
26+ 2. Create an S3 bucket for your logs in the same region as your Elasticsearch
1527 database.
1628
17- 2 . Create an IAM user to run the backup and restore. Give your IAM user
18- permission to read/write from the bucket you created in step 1 . The
29+ 3 . Create an IAM user to run the backup and restore. Give your IAM user
30+ permission to read/write from the bucket you created in step 2 . The
1931 elasticsearch-cloud-aws plugin documentation has [instructions on setting
2032 up these permissions](https://github.com/elastic/elasticsearch-cloud-aws/tree/v2.5.1/#recommended-s3-permissions);
2133 adding the following as an inline custom policy should be sufficient
@@ -55,24 +67,33 @@ Recommended setup for running as an app on Aptible:
5567
5668 ```
5769
58- 3. Create an app in your [Aptible dashboard](https://dashboard.aptible.com) for
59- the cron. In the steps that follow, we'll use <YOUR_APP_HANDLE>
60- anywhere that you should substitute the actual app handle the results from
61- this step in the instructions.
70+ 4. Create an app in your Aptible account for the cron. You can do this through
71+ the [Aptible dashboard](https://dashboard.aptible.com) or using the
72+ [Aptible CLI](https://github.com/aptible/aptible-cli):
6273
63- 4. Use the [Aptible CLI](https://github.com/aptible/aptible-cli) to set the
64- following environment variables in your app:
74+ ```
75+ aptible apps:create YOUR_APP_HANDLE
76+ ```
77+
78+ In the steps that follow, we'll use <YOUR_APP_HANDLE> anywhere that
79+ you should substitute the actual app handle you've specified in this step.
80+
81+ 5. Set the following environment variables in your app's configuration:
6582
6683 * `DATABASE_URL`: Your Elasticsearch URL.
6784 * `S3_BUCKET`: Your S3 Bucket name.
68- * `S3_ACCESS_KEY_ID`: The access key you generated in step 2 .
69- * `S3_SECRET_ACCESS_KEY`: The secret key you generated in step 2 .
85+ * `S3_ACCESS_KEY_ID`: The access key you generated in step 3 .
86+ * `S3_SECRET_ACCESS_KEY`: The secret key you generated in step 3 .
7087
71- In addition, the following environment variables are optional:
88+ You may also wish to override any of the following optional environment
89+ variables:
7290
7391 * `MAX_DAYS_TO_KEEP`: The number of days of live logstash indexes you'd
7492 like to keep in your Elasticsearch instance. Any indexes from before this
7593 point will be archived by the cron. Defaults to 30.
94+ * `CRON_SCHEDULE`: The schedule for your backups. Defaults to "0 2 * * *",
95+ which runs nightly at 2 A.M. Make sure to escape any asterisks when
96+ setting this variable from the command line to avoid shell expansion.
7697 * `S3_REGION`: The region your Elasticsearch instance and S3 bucket live in.
7798 Defaults to `us-east-1`.
7899 * `REPOSITORY_NAME`: The name of your Elasticsearch snapshot repo. This is
@@ -87,7 +108,7 @@ Recommended setup for running as an app on Aptible:
87108 aptible config:set NAME=VALUE --app YOUR_APP_HANDLE
88109 ```
89110
90- 5 . Clone this repository and push it to your Aptible app:
111+ 6 . Clone this repository and push it to your Aptible app:
91112
92113 ```
93114 git clone https://github.com/aptible/elasticsearch-logstash-s3-backup.git
@@ -100,28 +121,31 @@ Recommended setup for running as an app on Aptible:
100121
101122The cron run by this app will execute daily and log its progress to stdout.
102123
103- To restore an index, you can use the `restore-index.sh` script included in this
104- repository. Just use the Aptible CLI to SSH into an app container :
124+ To test the backup or run it manually, use the Aptible CLI to run the
125+ `backup-all-indexes.sh` script in a container over SSH:
105126
106127```
107- aptible ssh --app YOUR_APP_HANDLE
128+ aptible ssh --app YOUR_APP_HANDLE ./backup-all-indexes.sh
108129```
109130
110- And, from there, run `restore-index.sh` with the name of the index you want to
111- restore, for example:
131+ To restore an index, you can use the `restore-index.sh` script included in this
132+ repository with the Aptible CLI. For example, to load the index for July 10, 2015,
133+ run:
112134
113135```
114- # /bin/bash /opt/scripts/ restore-index.sh logstash-2015-07-09
136+ aptible ssh --app YOUR_APP_HANDLE ./ restore-index.sh logstash-2015-07-10
115137```
116138
117139This will load the index back into your Elasticsearch instance. Note that if
118140you load an archived index into the same instance that you are running this
119141cron against, the index will get removed at the end of the day. Alternatively,
120142you can load the index into a different Elasticsearch instance by overriding
121- the `DATABASE_URL` environment variable:
143+ the `DATABASE_URL` environment variable in an SSH session before you run the
144+ restore script:
122145
123146```
124- # DATABASE_URL=https://some-other-elasticsearch /bin/bash /opt/scripts/restory-index.sh logstash-2015-07-09
147+ $ aptible ssh --app YOUR_APP_HANDLE bash
148+ bash-4.3# DATABASE_URL=https://some-other-elasticsearch ./restore-index.sh logstash-2015-07-09
125149```
126150
127151## Copyright and License
0 commit comments