mirror of
https://github.com/tiredofit/docker-db-backup.git
synced 2025-12-21 21:33:28 +01:00
Add initial sqlite3 support
This commit is contained in:
@@ -30,6 +30,7 @@ RUN set -ex && \
|
|||||||
postgresql \
|
postgresql \
|
||||||
postgresql-client \
|
postgresql-client \
|
||||||
redis \
|
redis \
|
||||||
|
sqlite \
|
||||||
xz \
|
xz \
|
||||||
zstd \
|
zstd \
|
||||||
&& \
|
&& \
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ case "$dbtype" in
|
|||||||
dbport=${DB_PORT:-6379}
|
dbport=${DB_PORT:-6379}
|
||||||
[[ ( -n "${DB_PASS}" || ( -n "${DB_PASS_FILE}" ) ) ]] && file_env 'DB_PASS'
|
[[ ( -n "${DB_PASS}" || ( -n "${DB_PASS_FILE}" ) ) ]] && file_env 'DB_PASS'
|
||||||
;;
|
;;
|
||||||
|
"sqlite" | "sqlite3" | "SQLITE" | "SQLITE3" )
|
||||||
|
dbtype=sqlite3
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
### Set Defaults
|
### Set Defaults
|
||||||
@@ -241,6 +244,22 @@ backup_redis() {
|
|||||||
move_backup
|
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() {
|
check_availability() {
|
||||||
### Set the Database Type
|
### Set the Database Type
|
||||||
case "$dbtype" in
|
case "$dbtype" in
|
||||||
@@ -309,6 +328,15 @@ check_availability() {
|
|||||||
print_warn "Redis Host '${dbhost}' is not accessible, retrying.. ($COUNTER seconds so far)"
|
print_warn "Redis Host '${dbhost}' is not accessible, retrying.. ($COUNTER seconds so far)"
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
|
"sqlite3" )
|
||||||
|
if [[ ! -e "${dbhost}" ]]; then
|
||||||
|
print_error "File '${dbhost}' does not exist."
|
||||||
|
elif [[ ! -f "${dbhost}" ]]; then
|
||||||
|
print_error "File '${dbhost}' is not a file."
|
||||||
|
elif [[ ! -r "${dbhost}" ]]; then
|
||||||
|
print_error "File '${dbhost}' is not readable."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,6 +505,10 @@ print_debug "Backup routines Initialized on $(date)"
|
|||||||
check_availability
|
check_availability
|
||||||
backup_redis
|
backup_redis
|
||||||
;;
|
;;
|
||||||
|
"sqlite3" )
|
||||||
|
check_availability
|
||||||
|
backup_sqlite3
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
### Zabbix
|
### Zabbix
|
||||||
|
|||||||
Reference in New Issue
Block a user