grafana / database-migrator

Code to export grafana.db (sqlite) to MySQL-compatible SQL file, to assist in migration of Grafana data to MySQL-compatible DB.
Apache License 2.0
95 stars 15 forks source link

awk error #10

Open Sallaxer opened 1 year ago

Sallaxer commented 1 year ago

When running the script I'm getting messages like: awk: escape.awk: line 4: syntax error at or near ,

In dump grafana.sql only this:

TRUNCATE TABLE alert;
TRUNCATE TABLE alert_configuration;
TRUNCATE TABLE ngalert_configuration;
TRUNCATE TABLE alert_image;
TRUNCATE TABLE org;
TRUNCATE TABLE alert_instance;
TRUNCATE TABLE org_user;
TRUNCATE TABLE alert_notification;
TRUNCATE TABLE permission;
TRUNCATE TABLE alert_notification_state;
TRUNCATE TABLE playlist;
TRUNCATE TABLE alert_rule;
TRUNCATE TABLE playlist_item;
TRUNCATE TABLE alert_rule_tag;
TRUNCATE TABLE plugin_setting;
TRUNCATE TABLE alert_rule_version;
TRUNCATE TABLE preferences;
TRUNCATE TABLE annotation;
TRUNCATE TABLE provenance_type;
TRUNCATE TABLE annotation_tag;
TRUNCATE TABLE query_history;
TRUNCATE TABLE api_key;
TRUNCATE TABLE query_history_star;
TRUNCATE TABLE builtin_role;
TRUNCATE TABLE quota;
TRUNCATE TABLE cache_data;
TRUNCATE TABLE role;
TRUNCATE TABLE correlation;
TRUNCATE TABLE secrets;
TRUNCATE TABLE dashboard;
TRUNCATE TABLE seed_assignment;
TRUNCATE TABLE dashboard_acl;
TRUNCATE TABLE server_lock;
TRUNCATE TABLE dashboard_provisioning;
TRUNCATE TABLE session;
TRUNCATE TABLE dashboard_public;
TRUNCATE TABLE short_url;
TRUNCATE TABLE dashboard_snapshot;
TRUNCATE TABLE star;
TRUNCATE TABLE dashboard_tag;
TRUNCATE TABLE tag;
TRUNCATE TABLE dashboard_version;
TRUNCATE TABLE team;
TRUNCATE TABLE data_keys;
TRUNCATE TABLE team_member;
TRUNCATE TABLE data_source;
TRUNCATE TABLE team_role;
TRUNCATE TABLE entity_event;
TRUNCATE TABLE temp_user;
TRUNCATE TABLE file;
TRUNCATE TABLE test_data;
TRUNCATE TABLE file_meta;
TRUNCATE TABLE user;
TRUNCATE TABLE kv_store;
TRUNCATE TABLE user_auth;
TRUNCATE TABLE library_element;
TRUNCATE TABLE user_auth_token;
TRUNCATE TABLE library_element_connection;
TRUNCATE TABLE user_role;
TRUNCATE TABLE login_attempt

Grafana 9.2.3 SQLite 3.27.2 MySQL Ver 8.0.29-21 for Linux on x86_64 (Percona Server (GPL), Release '21', Revision 'c59f87d2854')

Method from this issue https://github.com/grafana/database-migrator/issues/3 didn`t help ((

jepp-igus commented 1 year ago

Had the same issue, install and try to use "gawk".

I replaced the last line in the shell script like this

done | sqlite3 $DB | sed -e 's/\\[rnut"]/\\&/g' |  gawk -f escape.awk
Sallaxer commented 1 year ago

Had the same issue, install and try to use "gawk".

I replaced the last line in the shell script like this

done | sqlite3 $DB | sed -e 's/\\[rnut"]/\\&/g' |  gawk -f escape.awk

Thanks a lot. It works!

boomam commented 1 year ago

Same issue for me too, same resolution as suggested by @jepp-igus

Timmphy commented 1 year ago

Works with solution from @jepp-igus. Thank you :)