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 replicate flags to pump Litestream manually #488

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

Conversation

hifi
Copy link
Collaborator

@hifi hifi commented Jun 21, 2023

For some special setups it is sometimes useful to run Litestream manually instead of letting it replicate in the background.

This commit implements the following flags for replicate:

  • -once for doing synchronous replication and then exit
  • -force-snapshot to force a snapshot during -once
  • -enforce-retention to enforce retention rules during -once

Because running once does not respect the snapshot interval the caller is expected to use -force-snapshot and -enforce-retention regularly to ensure the replication targets stay clean.

For this to work correctly with a live database it needs to be opened with auto checkpointing disabled and SQLITE_FCNTL_PERSIST_WAL.

Other uses include only using -force-snapshot to create regular backups of the database instead of live replication.

Fixes #486


This PR is still WIP but it'd be nice to hear suggestions around the implementation and leveraging the exec stuff. Screwing around checkpointing by changing the values feels quite dirty. MinCheckpointPageN is checked on Open() so in most normal runs the added check for it to be non-zero doesn't make a difference.

@hifi hifi force-pushed the for-upstream/replicate-once branch from 072a755 to fe5f922 Compare June 21, 2023 11:34
For some special setups it is sometimes useful to run Litestream
manually instead of letting it replicate in the background.

This commit implements the following flags for replicate:

  * -once for doing synchronous replication and then exit
  * -force-snapshot to force a snapshot during -once
  * -enforce-retention to enforce retention rules during -once

Because running once does not respect the snapshot interval the
caller is expected to use -force-snapshot and -enforce-retention
regularly to ensure the replication targets stay clean.

For this to work correctly with a live database it needs to be opened
with auto checkpointing disabled and SQLITE_FCNTL_PERSIST_WAL.

Other uses include only using -force-snapshot to create regular backups
of the database instead of live replication.

Fixes benbjohnson#486
@hifi hifi force-pushed the for-upstream/replicate-once branch from fe5f922 to 9474f95 Compare October 20, 2023 05:15
@jtoar
Copy link

jtoar commented Jan 8, 2024

Hey @hifi, I just started using Litestream and was interested in using this feature. I'm still a bit of a novice Go programmer but am eager to help if I can. Would comments still be helpful? Or anything else I could do?

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.

Add -once and -force-snapshot arguments to replicate command
2 participants