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

How to sync to s3? #66

Open
spirobel opened this issue Jan 12, 2024 · 4 comments
Open

How to sync to s3? #66

spirobel opened this issue Jan 12, 2024 · 4 comments

Comments

@spirobel
Copy link

what is the commandline option to sync to s3?
I see --sync-from s3 but it seems like the docs for sync to s3 are missing.

Kind Regards,
spirobel

@losfair
Copy link
Member

losfair commented Jan 12, 2024

Hi,

Please check the docs for setting up sync to S3.

@spirobel
Copy link
Author

@losfair how to do it with the self hosted version?

@tionis
Copy link

tionis commented Sep 17, 2024

@spirobel There is no built-in way, you can however use litestream to replicate to s3/sftp with or without encryption. I implemented this using the following Dockerfile:

FROM litestream/litestream AS litestream

FROM ghcr.io/denoland/denokv:latest AS denokv

FROM debian:latest
COPY --from=litestream /usr/local/bin/litestream /usr/local/bin/litestream
COPY --from=denokv /usr/local/bin/denokv /usr/local/bin/denokv

RUN apt update && apt upgrade -y
RUN apt install openssh-client -y

ENV DENO_KV_SQLITE_PATH="/data/denokv.sqlite3"

RUN mkdir -p ~/.ssh
RUN ssh-keyscan zh2587s2.rsync.net >> ~/.ssh/known_hosts

COPY litestream.yml /etc/litestream.yml
COPY start.sh /usr/local/bin/start.sh

ENTRYPOINT ["/usr/local/bin/start.sh"]

and start.sh

#!/bin/sh
echo "$SSH_PRIV_KEY" | base64 -d >~/.ssh/id_ed25519
echo "$SSH_PUB_KEY" | base64 -d >~/.ssh/id_ed25519.pub
if ! test -d /data; then
	mkdir /data
fi
if ! test -f /data/denokv.sqlite3; then
	litestream restore /data/denokv.sqlite3
fi
# acquite some distributed lock here?
litestream replicate -exec '/usr/local/bin/denokv serve'

and successfully deployed it on fly.io and have been using it since then.

(The docker container also automatically restores the database from backup if it does not exist, the operator has to ensure that there are no two versions of the container running at any time.)

@tionis
Copy link

tionis commented Sep 17, 2024

Oh, and my litestream config looks like this:

dbs:
  - path: /data/denokv.sqlite3
    replicas:
      - type: sftp
        host: zh2587s2.rsync.net:22
        user: zh2587s2
        path: litestream/denokv
        key-path: ${HOME}/.ssh/id_ed25519
        age:
          identities:
            - ${AGE_PRIVATE_KEY}
          recipients:
            - ${AGE_PUBLIC_KEY}

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

No branches or pull requests

3 participants