Created
March 5, 2021 19:17
-
-
Save Yoshyn/c4d8feb0818665b4030a6eb2dec5d3ed to your computer and use it in GitHub Desktop.
Docker & Sqlite3 backup. Volume manipulation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# docker build -f sqlite3.Dockerfile -t sqlite3:local . | |
# docker run --rm -it -v sqlite-db-volume:/db sqlite3:local my_app.db | |
FROM alpine:latest | |
RUN apk add --update sqlite | |
RUN mkdir /db | |
WORKDIR /db | |
ENTRYPOINT ["sqlite3"] | |
CMD ["my_app.db"] | |
# Backup | |
# docker run --rm -it -v sqlite-db-volume:/db sqlite3:local my_app.db .dump >> dump.sql | |
# OR (not using file direclty) | |
# docker run --rm -it -v $(pwd):/dump -v sqlite-db-volume:/db alpine:latest cp /db/my_app.db /dump | |
# Restore | |
# cat dump.sql | docker run --rm -i -v sqlite-db-volume:/db sqlite3:local my_app.db | |
# OR inverse operation of copy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table test_table(id int, description varchar(10)); | |
insert into test_table values(1, 'foo'); | |
insert into test_table values(2, 'bar'); | |
select * from test_table; | |
.exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment