Add scripts and new Dockerfile for SQLite backups
This commit is contained in:
parent
5c97af4fb3
commit
37dc8be78d
|
@ -0,0 +1,3 @@
|
|||
# Helper Scripts
|
||||
|
||||
These are some pre-written pre/post backup/restore scripts that can be used for some common usecases. Eg. Backing up a SQLite database.
|
|
@ -0,0 +1,15 @@
|
|||
FROM vividboarder/docker-duplicity-cron
|
||||
MAINTAINER ViViDboarder <vividboarder@gmail.com>
|
||||
|
||||
# Install SQLite
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends sqlite3 \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/apt/lists/*
|
||||
|
||||
# Copy SQLite backup scripts
|
||||
COPY ./backup /scripts/backup
|
||||
COPY ./restore /scripts/restore
|
||||
|
||||
# Env that points to sqlite db
|
||||
ENV DB_PATH /data/db.sqlite3
|
|
@ -0,0 +1,3 @@
|
|||
# SQLite Backup Scripts
|
||||
|
||||
Add these to your image and then set an env variable `$DB_PATH` that points to the database file you wish to backup. This will use the proper SQLite backup command for backups.
|
|
@ -0,0 +1,6 @@
|
|||
set -e
|
||||
|
||||
cd /data
|
||||
|
||||
# Remove backed up copy
|
||||
rm "$DB_PATH.bak"
|
|
@ -0,0 +1,6 @@
|
|||
set -e
|
||||
|
||||
cd /data
|
||||
|
||||
# Dump the SQLite database
|
||||
sqlite3 "$DB_PATH" ".backup $DB_PATH.bak"
|
|
@ -0,0 +1,6 @@
|
|||
set -e
|
||||
|
||||
cd /data
|
||||
|
||||
# Restore the backedup database
|
||||
mv "$DB_PATH.bak" "$DB_PATH"
|
|
@ -0,0 +1,3 @@
|
|||
set -e
|
||||
|
||||
# Don't really need to do anything here
|
Loading…
Reference in New Issue