mirror of
https://github.com/tiredofit/docker-db-backup.git
synced 2025-12-21 21:33:28 +01:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f005956c47 | ||
|
|
ba20386e65 | ||
|
|
12211d3b67 | ||
|
|
83693d35b2 | ||
|
|
52b726c821 | ||
|
|
5c43b3c907 |
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@@ -0,0 +1 @@
|
||||
examples/
|
||||
25
CHANGELOG.md
25
CHANGELOG.md
@@ -1,3 +1,28 @@
|
||||
## 3.3.7 2022-06-23 <dave at tiredofit dot ca>
|
||||
|
||||
### Changed
|
||||
- Allow overrides to actually override with the restore script
|
||||
|
||||
|
||||
## 3.3.6 2022-06-23 <dave at tiredofit dot ca>
|
||||
|
||||
### Changed
|
||||
- Fix for restore script when using all 7 arguments
|
||||
|
||||
|
||||
## 3.3.5 2022-06-08 <dave at tiredofit dot ca>
|
||||
|
||||
### Changed
|
||||
- Fix DB Port parameter not being able to be input in restore script
|
||||
- Fix MongoDB restore questionnaire
|
||||
|
||||
|
||||
## 3.3.4 2022-06-03 <rozdzynski@github>
|
||||
|
||||
### Fixed
|
||||
- S3 backups failing with special characters in filename
|
||||
|
||||
|
||||
## 3.3.3 2022-05-24 <dave at tiredofit dot ca>
|
||||
|
||||
### Added
|
||||
|
||||
@@ -446,7 +446,7 @@ cleanup_old_data() {
|
||||
s3_olderthan=$(echo $(( $(date +%s)-${DB_CLEANUP_TIME}*60 )))
|
||||
if [[ $s3_createdate -le $s3_olderthan ]] ; then
|
||||
s3_filename=$(echo $s3_file | awk {'print $4'})
|
||||
if [ $s3_filename != "" ] ; then
|
||||
if [ "$s3_filename" != "" ] ; then
|
||||
print_debug "Deleting $s3_filename"
|
||||
silent aws ${PARAM_AWS_ENDPOINT_URL} s3 rm s3://${S3_BUCKET}/${S3_PATH}/${s3_filename} ${s3_ssl} ${s3_ca_cert} ${S3_EXTRA_OPTS}
|
||||
fi
|
||||
|
||||
@@ -55,7 +55,7 @@ The image will also allow you to use environment variables or Docker secrets use
|
||||
|
||||
The script can also be executed skipping the interactive mode by using the following syntax/
|
||||
|
||||
$(basename $0) <filename> <db_type> <db_hostname> <db_name> <db_user> <db_pass> <db_port>
|
||||
$(basename "$0") <filename> <db_type> <db_hostname> <db_name> <db_user> <db_pass> <db_port>
|
||||
|
||||
If you only enter some of the arguments you will be prompted to fill them in.
|
||||
|
||||
@@ -70,7 +70,7 @@ EOF
|
||||
interactive_mode=true
|
||||
;;
|
||||
* )
|
||||
interactive_mode=false
|
||||
interactive_mode=false
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
@@ -78,7 +78,7 @@ fi
|
||||
get_filename() {
|
||||
COLUMNS=12
|
||||
prompt="Please select a file to restore:"
|
||||
options=( $(find ${DB_DUMP_TARGET} -type f -maxdepth 1 -not -name '*.md5' -not -name '*.sha1' -print0 | xargs -0) )
|
||||
options=( $(find "${DB_DUMP_TARGET}" -type f -maxdepth 1 -not -name '*.md5' -not -name '*.sha1' -print0 | xargs -0) )
|
||||
PS3="$prompt "
|
||||
select opt in "${options[@]}" "Custom" "Quit" ; do
|
||||
if (( REPLY == 2 + ${#options[@]} )) ; then
|
||||
@@ -641,7 +641,7 @@ EOF
|
||||
2 )
|
||||
while true; do
|
||||
read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}C${cdgy}\) \| \(${cwh}E${cdgy}\) : ${cwh}${coff}) " q_dbport_menu
|
||||
case "${q_dbname_menu,,}" in
|
||||
case "${q_port_menu,,}" in
|
||||
c* )
|
||||
counter=1
|
||||
q_dbport=" "
|
||||
@@ -829,11 +829,7 @@ print_debug "Filename to recover '${r_filename}'"
|
||||
|
||||
## Question Database Type
|
||||
if [ -n "${2}" ]; then
|
||||
if [ ! -f "${2}" ]; then
|
||||
get_dbtype
|
||||
else
|
||||
r_dbtype="${2}"
|
||||
fi
|
||||
r_dbtype="${2}"
|
||||
else
|
||||
get_dbtype
|
||||
fi
|
||||
@@ -841,59 +837,39 @@ print_debug "Database type '${r_dbtype}'"
|
||||
|
||||
## Question Database Host
|
||||
if [ -n "${3}" ]; then
|
||||
if [ ! -f "${3}" ]; then
|
||||
get_dbhost
|
||||
else
|
||||
r_dbhost="${3}"
|
||||
fi
|
||||
r_dbhost="${3}"
|
||||
else
|
||||
get_dbhost
|
||||
fi
|
||||
print_debug "Database Host '${r_dbhost}'"
|
||||
|
||||
## Question Database Name
|
||||
if [ -n "${3}" ]; then
|
||||
if [ ! -f "${3}" ]; then
|
||||
get_dbname
|
||||
else
|
||||
r_dbname="${3}"
|
||||
fi
|
||||
if [ -n "${4}" ]; then
|
||||
r_dbname="${4}"
|
||||
else
|
||||
get_dbname
|
||||
fi
|
||||
print_debug "Database Name '${r_dbname}'"
|
||||
|
||||
## Question Database User
|
||||
if [ -n "${4}" ]; then
|
||||
if [ ! -f "${4}" ]; then
|
||||
get_dbuser
|
||||
else
|
||||
r_dbuser="${4}"
|
||||
fi
|
||||
if [ -n "${5}" ]; then
|
||||
r_dbuser="${5}"
|
||||
else
|
||||
get_dbuser
|
||||
fi
|
||||
print_debug "Database User '${r_dbuser}'"
|
||||
|
||||
## Question Database Password
|
||||
if [ -n "${5}" ]; then
|
||||
if [ ! -f "${5}" ]; then
|
||||
get_dbpass
|
||||
else
|
||||
r_dbpass="${5}"
|
||||
fi
|
||||
if [ -n "${6}" ]; then
|
||||
r_dbpass="${6}"
|
||||
else
|
||||
get_dbpass
|
||||
fi
|
||||
print_debug "Database Pass '${r_dbpass}'"
|
||||
|
||||
## Question Database Port
|
||||
if [ -n "${6}" ]; then
|
||||
if [ ! -f "${6}" ]; then
|
||||
get_dbport
|
||||
else
|
||||
r_dbport="${6}"
|
||||
fi
|
||||
if [ -n "${7}" ]; then
|
||||
r_dbport="${7}"
|
||||
else
|
||||
get_dbport
|
||||
fi
|
||||
@@ -944,12 +920,12 @@ case "${r_dbtype}" in
|
||||
mongo_compression="--gzip"
|
||||
fi
|
||||
if [ -n "${r_dbuser}" ] ; then
|
||||
mongo_user="-u ${r_dbuser}"
|
||||
mongo_user="-u=${r_dbuser}"
|
||||
fi
|
||||
if [ -n "${r_dbpass}" ] ; then
|
||||
mongo_pass="-u ${r_dbpass}"
|
||||
mongo_pass="-p=${r_dbpass}"
|
||||
fi
|
||||
mongorestore ${mongo_compression} -d ${r_dbname} -h ${r_dbhost} --port ${r_dbport} ${mongo_user} ${mongo_pass} --archive=${r_filename}
|
||||
mongorestore ${mongo_compression} -d=${r_dbname} -h=${r_dbhost} --port=${r_dbport} ${mongo_user} ${mongo_pass} --archive=${r_filename}
|
||||
exit_code=$?
|
||||
;;
|
||||
* )
|
||||
|
||||
Reference in New Issue
Block a user