Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grafana Backup Tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Migrated Projects
Tooling
Grafana Backup Tool
Commits
bfc4a610
Unverified
Commit
bfc4a610
authored
3 years ago
by
Aaron Johnson
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #141 from acjohnson/tommyjcarpenter-fixes
Add error handling for nonexistent key
parents
e945a2fe
f56087c7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+27
-2
27 additions, 2 deletions
CHANGELOG.md
grafana_backup/constants.py
+6
-6
6 additions, 6 deletions
grafana_backup/constants.py
grafana_backup/s3_download.py
+18
-18
18 additions, 18 deletions
grafana_backup/s3_download.py
with
51 additions
and
26 deletions
CHANGELOG.md
+
27
−
2
View file @
bfc4a610
...
...
@@ -4,6 +4,31 @@ All notable changes to this project will be documented in this file.
The format is based on
[
Keep a Changelog
](
https://keepachangelog.com/en/1.0.0/
)
,
and this project adheres to
[
Semantic Versioning
](
https://semver.org/spec/v2.0.0.html
)
.
# [1.1.9] - 2021-06-27
### Added
-
c6b6f68 Create python-publish.yml
-
#100 GCS support
### Changed
-
#92 better error message when the user specifies a bad S3 key
-
#135 Update main organization instead of creating a new one
-
#133 Creating the docker container without these packages didn't work
-
#139 windows env var fix
### Removed
# [1.1.8] - 2021-04-14
### Added
### Changed
-
#124 fixed #123
-
#121 multi arch docker support
-
#127 add azure storage support
### Removed
# [1.1.7] - 2021-01-13
### Added
...
...
@@ -28,7 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
### Changed
-
#104 added python2 support to restore functions
-
#104 added python2 support to restore functions
-
#105 add configuration attribute to set backup file name
-
#112 changed restore_functions to ordered dict
-
#113 [Fixed] Dashboards with same name in different folders not restored
...
...
@@ -52,7 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
-
#83 Fix tarfile options for python2
-
#64 Remove empty folders when backup file (.tar.gz) created.
-
#64 Remove empty folders when backup file (.tar.gz) created.
# [1.1.2] - 2020-08-14
...
...
This diff is collapsed.
Click to expand it.
grafana_backup/constants.py
+
6
−
6
View file @
bfc4a610
import
os
if
os
.
name
==
'
nt
'
:
homedir
=
os
.
environ
[
'
HOMEPATH
'
]
if
os
.
name
==
"
nt
"
:
homedir
=
os
.
environ
[
"
HOMEPATH
"
]
else
:
homedir
=
os
.
environ
[
'
HOME
'
]
homedir
=
os
.
environ
[
"
HOME
"
]
PKG_NAME
=
'
grafana-backup
'
PKG_VERSION
=
'
1.1.
8
'
JSON_CONFIG_PATH
=
'
{0}/.grafana-backup.json
'
.
format
(
homedir
)
PKG_NAME
=
"
grafana-backup
"
PKG_VERSION
=
"
1.1.
9
"
JSON_CONFIG_PATH
=
"
{0}/.grafana-backup.json
"
.
format
(
homedir
)
This diff is collapsed.
Click to expand it.
grafana_backup/s3_download.py
+
18
−
18
View file @
bfc4a610
import
boto3
from
botocore.exceptions
import
NoCredentialsError
from
botocore.exceptions
import
NoCredentialsError
,
ClientError
def
main
(
args
,
settings
):
arg_archive_file
=
args
.
get
(
'
<archive_file>
'
,
None
)
aws_s3_bucket_name
=
settings
.
get
(
'
AWS_S3_BUCKET_NAME
'
)
aws_s3_bucket_key
=
settings
.
get
(
'
AWS_S3_BUCKET_KEY
'
)
aws_default_region
=
settings
.
get
(
'
AWS_DEFAULT_REGION
'
)
aws_access_key_id
=
settings
.
get
(
'
AWS_ACCESS_KEY_ID
'
)
aws_secret_access_key
=
settings
.
get
(
'
AWS_SECRET_ACCESS_KEY
'
)
aws_endpoint_url
=
settings
.
get
(
'
AWS_ENDPOINT_URL
'
)
arg_archive_file
=
args
.
get
(
"
<archive_file>
"
,
None
)
aws_s3_bucket_name
=
settings
.
get
(
"
AWS_S3_BUCKET_NAME
"
)
aws_s3_bucket_key
=
settings
.
get
(
"
AWS_S3_BUCKET_KEY
"
)
aws_default_region
=
settings
.
get
(
"
AWS_DEFAULT_REGION
"
)
aws_access_key_id
=
settings
.
get
(
"
AWS_ACCESS_KEY_ID
"
)
aws_secret_access_key
=
settings
.
get
(
"
AWS_SECRET_ACCESS_KEY
"
)
aws_endpoint_url
=
settings
.
get
(
"
AWS_ENDPOINT_URL
"
)
session
=
boto3
.
Session
(
aws_access_key_id
=
aws_access_key_id
,
aws_secret_access_key
=
aws_secret_access_key
,
region_name
=
aws_default_region
aws_access_key_id
=
aws_access_key_id
,
aws_secret_access_key
=
aws_secret_access_key
,
region_name
=
aws_default_region
)
s3
=
session
.
resource
(
service_name
=
'
s3
'
,
endpoint_url
=
aws_endpoint_url
)
s3
=
session
.
resource
(
service_name
=
"
s3
"
,
endpoint_url
=
aws_endpoint_url
)
s3_object
=
s3
.
Object
(
aws_s3_bucket_name
,
'
{0}/{1}
'
.
format
(
aws_s3_bucket_key
,
arg_archive_file
))
s3_path
=
"
{0}/{1}
"
.
format
(
aws_s3_bucket_key
,
arg_archive_file
)
s3_object
=
s3
.
Object
(
aws_s3_bucket_name
,
s3_path
)
try
:
# .read() left off on purpose, tarfile.open() takes care of that part
s3_data
=
s3_object
.
get
()[
'
Body
'
]
s3_data
=
s3_object
.
get
()[
"
Body
"
]
print
(
"
Download from S3 was successful
"
)
except
ClientError
as
e
:
if
e
.
response
[
"
Error
"
][
"
Code
"
]
==
"
NoSuchKey
"
:
print
(
"
Error: Key {0} does not exist in bucket {1}
"
.
format
(
s3_path
,
aws_s3_bucket_name
))
return
False
raise
e
except
NoCredentialsError
:
print
(
"
Credentials not available
"
)
return
False
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment