Skip to content

Instantly share code, notes, and snippets.

@shirish87
Created February 23, 2020 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirish87/fd9b1297036bdf122aeb135fa8af09ad to your computer and use it in GitHub Desktop.
Save shirish87/fd9b1297036bdf122aeb135fa8af09ad to your computer and use it in GitHub Desktop.
#!/bin/bash -e
dest="$(date '+%Y-%m-%d')-snapshot"
container="${1:-influxdb-1}"
db="${2:-comp_prices}"
destpath="/tmp/${dest}"
destfile="/tmp/${dest}.tgz"
docker exec -it $container influxd backup -portable -database $db "$destpath"
docker exec -it $container tar -czf "$destfile" "$destpath"
docker cp "$container:$destfile" .
docker exec -it $container rm -rf "$destpath"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment