Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why dashboard_versions directory is not included in produced backup file? #177

Closed
flphvlck opened this issue Mar 1, 2022 · 6 comments · Fixed by #229
Closed

Why dashboard_versions directory is not included in produced backup file? #177

flphvlck opened this issue Mar 1, 2022 · 6 comments · Fixed by #229

Comments

@flphvlck
Copy link

flphvlck commented Mar 1, 2022

Hi, this is more question than issue..
Why dashboard_versions directory is not included in produced backup file? I use S3 storage and uploaded backup file (e.g. 202203011336.tar.gz) doesn't contain dashboard_versions directory.
Thanks.

@chriz-active
Copy link
Contributor

The same happened on my side.
When using grafana-backup save the dashboard_versions directory is not part of the created zip-file but lies next to the zip-file uncompressed.

Tested with a python:3.11.4-alpine3.18 docker image and data stored on a virtual machine with the current master branch (and minimal adjustments due to the hide_version issue #225 ) - current master is this commit: 3dd9d71

Yet, not tested what this means for restoring.

@chriz-active
Copy link
Contributor

@ysde

To me this looks as 'versions' mean here dashboard-versions.

--components=<> Comma separated list of individual components to backup (all by default); versions can only be saved not restored.
<folders,folder_permissions,dashboards,datasources,alert-channels,alert-rules,organizations,users,snapshots,versions,annotations,library_elements,teams,team_members>

Which are saved with the help of this:
https://github.com/ysde/grafana-backup-tool/blob/3dd9d71a48a58484ac4b60cdebb5eb1235e95246/grafana_backup/save_versions.py

Especially with this folder-name:

folder_path = '{0}/dashboard_versions/{1}'.format(backup_dir, timestamp)

But in the archive I only can find the folder_name versions

for folder_name in ['folders', 'datasources', 'dashboards', 'alert_channels', 'organizations', 'users', 'snapshots',

Question 1: Are versions and dashboard-versions the same?
Question 2: Is there a special reason (like making clear, that they cannot be restored), that exclude them from the archive?

@chriz-active
Copy link
Contributor

I think this would be a patch:

diff --git a/grafana_backup/archive.py b/grafana_backup/archive.py
index 71b37bf..1db698a 100755
--- a/grafana_backup/archive.py
+++ b/grafana_backup/archive.py
@@ -10,7 +10,7 @@ def main(args, settings):
     backup_files = list()
 
     for folder_name in ['folders', 'datasources', 'dashboards', 'alert_channels', 'organizations', 'users', 'snapshots',
-                        'versions', 'annotations', 'library-elements', 'teams', 'team_members', 'alert_rules']:
+                        'dashboard_versions', 'annotations', 'library-elements', 'teams', 'team_members', 'alert_rules']:
         backup_path = '{0}/{1}/{2}'.format(backup_dir, folder_name, timestamp)
 
         for file_path in glob(backup_path):
diff --git a/grafana_backup/cli.py b/grafana_backup/cli.py
index b99b47d..051ed31 100755
--- a/grafana_backup/cli.py
+++ b/grafana_backup/cli.py
@@ -24,8 +24,8 @@ Options:
     -h --help                               Show this help message and exit
     --version                               Get version information and exit
     --config=<filename>                     Override default configuration path
-    --components=<>                         Comma separated list of individual components to backup (all by default); versions can only be saved not restored.
-                                            <folders,folder_permissions,dashboards,datasources,alert-channels,alert-rules,organizations,users,snapshots,versions,annotations,library_elements,teams,team_members>
+    --components=<>                         Comma separated list of individual components to backup (all by default); dashboard-versions can only be saved not restored.
+                                            <folders,folder_permissions,dashboards,datasources,alert-channels,alert-rules,organizations,users,snapshots,dashboard-versions,annotations,library_elements,teams,team_members>
 
     --no-archive                            Skip archive creation and do not delete unarchived files
                                             (used for troubleshooting purposes)
diff --git a/grafana_backup/save.py b/grafana_backup/save.py
index bb67ada..7c06814 100755
--- a/grafana_backup/save.py
+++ b/grafana_backup/save.py
@@ -5,7 +5,7 @@ from grafana_backup.save_datasources import main as save_datasources
 from grafana_backup.save_folders import main as save_folders
 from grafana_backup.save_alert_channels import main as save_alert_channels
 from grafana_backup.save_snapshots import main as save_snapshots
-from grafana_backup.save_versions import main as save_versions
+from grafana_backup.save_dashboard_versions import main as save_dashboard_versions
 from grafana_backup.save_annotations import main as save_annotations
 from grafana_backup.archive import main as archive
 from grafana_backup.s3_upload import main as s3_upload
@@ -31,7 +31,7 @@ def main(args, settings):
                         'organizations': save_orgs,
                         'users': save_users,
                         'snapshots': save_snapshots,
-                        'versions': save_versions,
+                        'dashboard-versions': save_dashboard_versions,
                         'annotations': save_annotations,
                         'library-elements': save_library_elements,
                         'teams': save_teams,
diff --git a/grafana_backup/save_versions.py b/grafana_backup/save_dashboard_versions.py
similarity index 100%
rename from grafana_backup/save_versions.py
rename to grafana_backup/save_dashboard_versions.py

@acjohnson
Copy link
Collaborator

@chriz-active Would you be willing to submit that as a PR?

@chriz-active
Copy link
Contributor

chriz-active commented Jul 12, 2023

If someone confirms that this repo is still maintained --- which it didn't look like the last few days - and I'm aware and appreciate a lot that people are doing open source projects in their spare time and it sometimes takes a bit longer. :)

  • the github-actions are outdated: hide_version-config: add version as config/env var #226 (comment)

    • my question wrt. to the outdated python2.7 was not answered yet, such that this PR wouldn't go through also...
  • questions aren't answered, such that I'm just guessing around, what the programmers intentions might was (is this a bug or a feature?)

  • currently we have forked the repo, since we need changes to be there within a reasonable amount of time, but we would love to not have the overhead of checking changes here and merging them in our forked repo all the time

@acjohnson
Copy link
Collaborator

@chriz-active Yes this repo is still maintained. I've commented on your PR #226

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants