mirror of
https://github.com/tiredofit/docker-db-backup.git
synced 2025-12-22 21:53:42 +01:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7d4f1cc19 | ||
|
|
c8c9a80533 | ||
|
|
018234b9bc | ||
|
|
912e60edd8 | ||
|
|
46fddb533c | ||
|
|
e8a1859d1a | ||
|
|
30fe2f181c | ||
|
|
f57ce461e9 |
3
.github/workflows/main.yml
vendored
3
.github/workflows/main.yml
vendored
@@ -70,9 +70,6 @@ jobs:
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
run: |
|
||||
docker buildx inspect --bootstrap
|
||||
|
||||
|
||||
- name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
|
||||
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,3 +1,15 @@
|
||||
## 2.6.0 2021-02-19 <tpansino@github>
|
||||
|
||||
### Added
|
||||
- SQLite support
|
||||
|
||||
|
||||
## 2.5.1 2021-02-14 <dave at tiredofit dot ca>
|
||||
|
||||
### Changed
|
||||
- Fix xz backups with `PARALLEL_COMPRESION=TRUE`
|
||||
|
||||
|
||||
## 2.5.0 2021-01-25 <dave at tiredofit dot ca>
|
||||
|
||||
### Added
|
||||
|
||||
@@ -22,6 +22,7 @@ RUN set -ex && \
|
||||
apk add --no-cache -t .db-backup-run-deps \
|
||||
bzip2 \
|
||||
influxdb \
|
||||
libarchive \
|
||||
mariadb-client \
|
||||
mongodb-tools \
|
||||
libressl \
|
||||
@@ -29,6 +30,7 @@ RUN set -ex && \
|
||||
postgresql \
|
||||
postgresql-client \
|
||||
redis \
|
||||
sqlite \
|
||||
xz \
|
||||
zstd \
|
||||
&& \
|
||||
|
||||
@@ -98,8 +98,8 @@ Along with the Environment Variables from the [Base image](https://hub.docker.co
|
||||
| `BACKUP_LOCATION` | Backup to `FILESYSTEM` or `S3` compatible services like S3, Minio, Wasabi - Default `FILESYSTEM` |
|
||||
| `COMPRESSION` | Use either Gzip `GZ`, Bzip2 `BZ`, XZip `XZ`, ZSTD `ZSTD` or none `NONE` - Default `GZ` |
|
||||
| `COMPRESSION_LEVEL` | Numberical value of what level of compression to use, most allow `1` to `9` except for `ZSTD` which allows for `1` to `19` - Default `3` |
|
||||
| `DB_TYPE` | Type of DB Server to backup `couch` `influx` `mysql` `pgsql` `mongo` `redis` |
|
||||
| `DB_HOST` | Server Hostname e.g. `mariadb` |
|
||||
| `DB_TYPE` | Type of DB Server to backup `couch` `influx` `mysql` `pgsql` `mongo` `redis` `sqlite3` |
|
||||
| `DB_HOST` | Server Hostname e.g. `mariadb`. For `sqlite3`, full path to DB file e.g. `/backup/db.sqlite3` |
|
||||
| `DB_NAME` | Schema Name e.g. `database` |
|
||||
| `DB_USER` | username for the database - use `root` to backup all MySQL of them. |
|
||||
| `DB_PASS` | (optional if DB doesn't require it) password for the database |
|
||||
|
||||
@@ -60,6 +60,9 @@ case "$dbtype" in
|
||||
dbport=${DB_PORT:-6379}
|
||||
[[ ( -n "${DB_PASS}" || ( -n "${DB_PASS_FILE}" ) ) ]] && file_env 'DB_PASS'
|
||||
;;
|
||||
"sqlite" | "sqlite3" | "SQLITE" | "SQLITE3" )
|
||||
dbtype=sqlite3
|
||||
;;
|
||||
esac
|
||||
|
||||
### Set Defaults
|
||||
@@ -241,6 +244,22 @@ backup_redis() {
|
||||
move_backup
|
||||
}
|
||||
|
||||
backup_sqlite3() {
|
||||
db=$(basename "$dbhost")
|
||||
db="${db%.*}"
|
||||
target=sqlite3_${db}_${now}.sqlite3
|
||||
compression
|
||||
|
||||
print_info "Dumping sqlite3 database: ${dbhost}"
|
||||
sqlite3 "${dbhost}" ".backup '${tmpdir}/backup.sqlite3'"
|
||||
exit_code=$?
|
||||
|
||||
cat "${tmpdir}/backup.sqlite3" | $dumpoutput > "${tmpdir}/${target}"
|
||||
|
||||
generate_md5
|
||||
move_backup
|
||||
}
|
||||
|
||||
check_availability() {
|
||||
### Set the Database Type
|
||||
case "$dbtype" in
|
||||
@@ -309,6 +328,21 @@ check_availability() {
|
||||
print_warn "Redis Host '${dbhost}' is not accessible, retrying.. ($COUNTER seconds so far)"
|
||||
done
|
||||
;;
|
||||
"sqlite3" )
|
||||
if [[ ! -e "${dbhost}" ]]; then
|
||||
print_error "File '${dbhost}' does not exist."
|
||||
exit_code=2
|
||||
exit $exit_code
|
||||
elif [[ ! -f "${dbhost}" ]]; then
|
||||
print_error "File '${dbhost}' is not a file."
|
||||
exit_code=2
|
||||
exit $exit_code
|
||||
elif [[ ! -r "${dbhost}" ]]; then
|
||||
print_error "File '${dbhost}' is not readable."
|
||||
exit_code=2
|
||||
exit $exit_code
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
@@ -477,6 +511,10 @@ print_debug "Backup routines Initialized on $(date)"
|
||||
check_availability
|
||||
backup_redis
|
||||
;;
|
||||
"sqlite3" )
|
||||
check_availability
|
||||
backup_sqlite3
|
||||
;;
|
||||
esac
|
||||
|
||||
### Zabbix
|
||||
|
||||
Reference in New Issue
Block a user