1

I am using below command to create snapshot with date appended to the filename but getting error as invalid snapshot name and it must be lowercase.

#!/bin/bash
SNAPSHOT=`date +%Y%m%d-%H%M%S`
curl -XPUT "localhost:9200/_snapshot/my_backup/$SNAPSHOT?wait_for_completion=true"

3 Answers3

2

You can use the following:

#!/bin/sh

filename=snapshot
current_time=$(date "+%Y.%m.%d-%H.%M.%S")

filename_ts=$file_name.$current_time

curl -L -o $(filename_ts) "localhost:9200/_snapshot/my_backup/$filename_ts?wait_for_completion=true"
Imad
  • 121
1

If I am at all able to guess what you are asking, try this.

#!/bin/bash
now=$(date +%Y%m%d-%H%M%S)
curl -XPUT "localhost:9200/_snapshot/my_backup/snapshot_$now?wait_for_completion=true"

There are a few hygiene edits, but the beef is adding snapshot_ as a prefix of the snapshot name, to make sure it's not all-numeric.

tripleee
  • 3,308
  • 5
  • 36
  • 35
1

Thanks everyone for your help :) I am able to get the query resolved .

Below command worked :

curl -XPUT http://localhost:9200/_snapshot/IMS/"snapshot$(date +%d%m%y-%H%M%S)" and this created the output file as snapshot31072019-145244 .