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

add data source influxdb #88

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

KiaraGrouwstra
Copy link

@KiaraGrouwstra KiaraGrouwstra marked this pull request as draft January 26, 2025 10:44
@KiaraGrouwstra KiaraGrouwstra changed the title [DRAFT] add data source influxdb add data source influxdb Jan 26, 2025
Copy link
Collaborator

@witten witten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exciting to see this addition! The overall approach here LGTM. I left some initial comments.. I realize this is still at a draft phase. To get this to shipping, it'll also need unit tests. You can have a look at some of the other database hooks for inspiration. Also, this: https://torsion.org/borgmatic/docs/how-to/develop-on-borgmatic/#automated-tests

Let me know if you have any questions. And thank you!

'''
Return whether dump streaming is used for this hook. (Spoiler: It isn't.)
'''
return False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be True, because you're actually using streaming (returning processes) below!

'''
Given a base directory, make the corresponding dump path.
'''
return dump.make_data_source_dump_path(base_directory, 'infludb_databases')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the "x" in "influxdb_databases". 😄

Comment on lines +69 to +70
if dry_run:
continue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could move this to after build_dump_command() so that a dry run simulates a little bit more before having to bail. Do not feel strongly.

Comment on lines +74 to +76
if dump_format == 'directory':
dump.create_parent_directory_for_dump(dump_filename)
execute_command(command, shell=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this correctly, this code path will never get hit, because there isn't a dump format in the schema.

database.get('hostname'),
database.get('port'),
)
dump_format = database.get('format', 'archive')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No dump format is present in the schema...?

token = connection_params['token'] or database.get('token')
return (
('influx-cli', 'backup',)
+ (('--skip-verify',) if skip_verify else ())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable doesn't look like it's set...? Same for several below.

Comment on lines +142 to +144
dump.make_data_source_dump_filename(
make_dump_path(borgmatic_source_directory), name, hostname='*'
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably safely remove this one. Use of the borgmatic "source directory" predates this InfluxDB hook, so there should be no old borgmatic archives with InfluxDB dumps in this source directory location.

Comment on lines +209 to +211
command = ['influx-cli', 'restore']
if hostname:
command.extend(('--host', hostname))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could construct this command declaratively instead of imperatively like you did in build_dump_command().

Do not feel strongly.

http_debug = database.get('http_debug')
full = database.get('full')

command = ['influx-cli', 'restore']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to dumping, you could consume the same config option here to allow the user to optionally override the influx-cli path. See other database hooks for examples.

def dump_data_sources(
databases,
config,
log_prefix,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads up that I have a branch where log prefix will be going away. Nothing for you to do about it now though.

https://projects.torsion.org/borgmatic-collective/borgmatic/pulls/980

type: string
description: |
HTTP address of InfluxDB.
default: http://127.0.0.1:8086
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I don't think these defaults are currently consumed by borgmatic, so they might not make it into the borgmatic config generate output. It'd be good to test that.

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 this pull request may close these issues.

2 participants