Compare commits

...

13 Commits

Author SHA1 Message Date
dave@tiredofit.ca
d5cacdb32a Release 3.10.5 - See CHANGELOG.md 2023-10-11 15:44:26 -07:00
dave@tiredofit.ca
238b4d852c Release 3.10.4 - See CHANGELOG.md 2023-10-11 15:17:54 -07:00
Dave Conroy
8d6e72eead Merge pull request #258 from thomas-negrault/fix/mongo-restore-authentication-database
Use authentification database in mongorestore
2023-10-11 15:16:42 -07:00
Thomas Negrault
a9037f97ac Use authentification database in mongorestore 2023-10-11 22:57:29 +02:00
dave@tiredofit.ca
ebcd4fcde4 Release 3.10.3 - See CHANGELOG.md 2023-10-11 12:31:25 -07:00
Dave Conroy
adf52c1160 Merge pull request #257 from thomas-negrault/fix/alphabetical-filenames-sorting
Sort filenames alphabetically when using the restore command
2023-10-11 12:30:26 -07:00
Thomas Negrault
1eee4a49d7 Sort filenames alphabetically when using the restore command 2023-10-11 18:41:05 +02:00
dave@tiredofit.ca
e3faab5c36 Release 3.10.2 - See CHANGELOG.md 2023-09-14 08:13:56 -07:00
Dave Conroy
768d5e60fe Merge pull request #252 from pimjansen/feature/name-typo
Updated name where it is not writing to s3
2023-09-14 08:12:39 -07:00
Dave Conroy
e3e0d7ed67 Merge pull request #251 from pimjansen/feature/split-db-use
Remove the --database flag for a single db dump
2023-09-14 08:03:41 -07:00
Pim Jansen
db808d25c7 Updated name where it is not writing to s3 2023-09-14 10:39:34 +02:00
Pim Jansen
cb5b49b90b Remove the --database flag for a single db dump which ensures there is no use statement in the dump 2023-09-14 10:36:55 +02:00
dave@tiredofit.ca
48a1ff8bbe Release 3.10.1 - See CHANGELOG.md 2023-09-13 22:37:21 -07:00
3 changed files with 77 additions and 11 deletions

View File

@@ -1,3 +1,37 @@
## 3.10.5 2023-10-11 <dave at tiredofit dot ca>
### Added
- Add option to drop exsiting data from MongoDB restore
### Changed
- Fix some capabilities of not being able to select mongodb manually to restore
## 3.10.4 2023-10-11 <thomas-negrault@github>
### Changed
- Use authentication database for MongoDB restores
## 3.10.3 2023-10-11 <thomas-negrault@github>
### Changed
- Change sorting for restore script
## 3.10.2 2023-09-14 <pimjansen@github>
### Changed
- Update to wording when sending files to blobxfer
- Remove --databases flag when backing up a single mysql/mariadb backup which allows to omit the "USE <db_name>" statement in the backup allowing for better restores
## 3.10.1 2023-09-13 <dave at tiredofit dot ca>
### Changed
- Bugfix to 3.10.0 with syntax error revolving around unbraced variable
## 3.10.0 2023-09-13 <jcdirks@github> ## 3.10.0 2023-09-13 <jcdirks@github>
### Added ### Added

View File

@@ -159,7 +159,7 @@ backup_influx() {
compression compression
pre_dbbackup $db pre_dbbackup $db
print_notice "Dumping Influx database: '${db}'" print_notice "Dumping Influx database: '${db}'"
influxd backup ${influx_compression} ${bucket} -portable -host ${DB_HOST}:${DB_PORT} ${EXTRA_OPTS ${EXTRA_DUMP_OPTS} "${TEMP_LOCATION}"/"${target_dir}" influxd backup ${influx_compression} ${bucket} -portable -host ${DB_HOST}:${DB_PORT} ${EXTRA_OPTS} ${EXTRA_DUMP_OPTS} "${TEMP_LOCATION}"/"${target_dir}"
exit_code=$? exit_code=$?
check_exit_code backup $target_dir check_exit_code backup $target_dir
print_notice "Creating archive file of '${target_dir}' with tar ${compression_string}" print_notice "Creating archive file of '${target_dir}' with tar ${compression_string}"
@@ -271,7 +271,7 @@ backup_mysql() {
compression compression
pre_dbbackup $db pre_dbbackup $db
print_notice "Dumping MySQL/MariaDB database: '${db}' ${compression_string}" print_notice "Dumping MySQL/MariaDB database: '${db}' ${compression_string}"
mysqldump --max-allowed-packet=${MYSQL_MAX_ALLOWED_PACKET} -h ${DB_HOST} -P ${DB_PORT} -u${DB_USER} ${single_transaction} ${stored_procedures} ${mysql_tls_args} ${EXTRA_OPTS} ${EXTRA_DUMP_OPTS} --databases $db | $compress_cmd > "${TEMP_LOCATION}"/"${target}" mysqldump --max-allowed-packet=${MYSQL_MAX_ALLOWED_PACKET} -h ${DB_HOST} -P ${DB_PORT} -u${DB_USER} ${single_transaction} ${stored_procedures} ${mysql_tls_args} ${EXTRA_OPTS} ${EXTRA_DUMP_OPTS} $db | $compress_cmd > "${TEMP_LOCATION}"/"${target}"
exit_code=$? exit_code=$?
check_exit_code backup $target check_exit_code backup $target
generate_checksum generate_checksum
@@ -748,7 +748,7 @@ move_dbbackup() {
rm -rf "${TEMP_LOCATION}"/"${target}" rm -rf "${TEMP_LOCATION}"/"${target}"
;; ;;
"blobxfer" ) "blobxfer" )
print_info "Moving backup to S3 Bucket with blobxfer" print_info "Moving backup to external storage with blobxfer"
mkdir -p "${DB_DUMP_TARGET}" mkdir -p "${DB_DUMP_TARGET}"
if var_true "${ENABLE_CHECKSUM}" ; then mv "${TEMP_LOCATION}"/*."${checksum_extension}" "${DB_DUMP_TARGET}"/; fi if var_true "${ENABLE_CHECKSUM}" ; then mv "${TEMP_LOCATION}"/*."${checksum_extension}" "${DB_DUMP_TARGET}"/; fi

View File

@@ -78,7 +78,7 @@ fi
get_filename() { get_filename() {
COLUMNS=12 COLUMNS=12
prompt="Please select a file to restore:" 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 | sort -z | xargs -0) )
PS3="$prompt " PS3="$prompt "
select opt in "${options[@]}" "Custom" "Quit" ; do select opt in "${options[@]}" "Custom" "Quit" ; do
if (( REPLY == 2 + ${#options[@]} )) ; then if (( REPLY == 2 + ${#options[@]} )) ; then
@@ -131,7 +131,7 @@ EOF
fi fi
if [ -z "${DB_HOST}" ] && [ -n "${parsed_host}" ]; then if [ -z "${DB_HOST}" ] && [ -n "${parsed_host}" ]; then
print_debug "Parsed DBHostpho Variant: 3 - No Env, Parsed Filename" print_debug "Parsed DBHost Variant: 3 - No Env, Parsed Filename"
q_dbhost_variant=3 q_dbhost_variant=3
q_dbhost_menu=$(cat <<EOF q_dbhost_menu=$(cat <<EOF
@@ -335,7 +335,7 @@ EOF
case "${q_dbtype_variant}" in case "${q_dbtype_variant}" in
1 ) 1 )
while true; do while true; do
read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}M${cdgy}\) | \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}M${cdgy}\) \| \(${cwh}O${cdgy}\) \| \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype
case "${q_dbtype,,}" in case "${q_dbtype,,}" in
m* ) m* )
r_dbtype=mysql r_dbtype=mysql
@@ -358,7 +358,7 @@ EOF
;; ;;
2 ) 2 )
while true; do while true; do
read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}E${cdgy}\) \| \(${cwh}M${cdgy}\) \| \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}E${cdgy}\) \| \(${cwh}M${cdgy}\) \| \(${cwh}O${cdgy}\) \| \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype
case "${q_dbtype,,}" in case "${q_dbtype,,}" in
e* | "" ) e* | "" )
r_dbtype=${DB_TYPE} r_dbtype=${DB_TYPE}
@@ -385,7 +385,7 @@ EOF
;; ;;
3 ) 3 )
while true; do while true; do
read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}F${cdgy}\) \| \(${cwh}M${cdgy}\) \| \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}F${cdgy}\) \| \(${cwh}M${cdgy}\) \| \(${cwh}O${cdgy}\) \| \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype
case "${q_dbtype,,}" in case "${q_dbtype,,}" in
f* | "" ) f* | "" )
r_dbtype=${p_dbtype} r_dbtype=${p_dbtype}
@@ -413,7 +413,7 @@ EOF
4 ) 4 )
while true; do while true; do
read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}E${cdgy}\) \| \(${cwh}F${cdgy}\) \| \(${cwh}M${cdgy}\) \| \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}E${cdgy}\) \| \(${cwh}F${cdgy}\) \| \(${cwh}M${cdgy}\) \| \(${cwh}O${cdgy}\) \| \(${cwh}P${cdgy}\) : ${cwh}${coff}) " q_dbtype
case "${q_dbtype,,}" in case "${q_dbtype,,}" in
e* | "" ) e* | "" )
r_dbtype=${DB_TYPE} r_dbtype=${DB_TYPE}
@@ -427,6 +427,10 @@ EOF
r_dbtype=mysql r_dbtype=mysql
break break
;; ;;
o* )
r_dbtype=mongo
break
;;
p* ) p* )
r_dbtype=postgresql r_dbtype=postgresql
break break
@@ -915,6 +919,30 @@ case "${r_dbtype}" in
exit_code=$? exit_code=$?
;; ;;
mongo ) mongo )
cat << EOF
Do you wish to drop any existing data before restoring?
Y ) Yes
N ) No
Q ) Quit
EOF
echo -e "${coff}"
read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}Y${cdgy}\) \| \(${cwh}N${cdgy}\) \| \(${cwh}Q${cdgy}\) : ${cwh}${coff})" q_menu_mongo_dropdb
case "${q_menu_mongo_dropdb,,}" in
"y" | "yes" | * )
mongo_dropdb="--drop"
;;
"n" | "update" )
unset mongo_dropdb
;;
"q" | "exit" )
print_info "Quitting Script"
exit 1
;;
esac
print_info "Restoring '${r_filename}' into '${r_dbhost}'/'${r_dbname}'" print_info "Restoring '${r_filename}' into '${r_dbhost}'/'${r_dbname}'"
if [ "${ENABLE_COMPRESSION,,}" != "none" ] && [ "${ENABLE_COMPRESSION,,}" != "false" ] ; then if [ "${ENABLE_COMPRESSION,,}" != "none" ] && [ "${ENABLE_COMPRESSION,,}" != "false" ] ; then
mongo_compression="--gzip" mongo_compression="--gzip"
@@ -925,7 +953,11 @@ case "${r_dbtype}" in
if [ -n "${r_dbpass}" ] ; then if [ -n "${r_dbpass}" ] ; then
mongo_pass="-p=${r_dbpass}" mongo_pass="-p=${r_dbpass}"
fi fi
mongorestore ${mongo_compression} -d=${r_dbname} -h=${r_dbhost} --port=${r_dbport} ${mongo_user} ${mongo_pass} --archive=${r_filename} if [ -n "${DB_AUTH}" ] ; then
mongo_auth_database="--authenticationDatabase=${DB_AUTH}"
fi
mongorestore ${mongo_compression} -d=${r_dbname} -h=${r_dbhost} --port=${r_dbport} ${mongo_dropdb} ${mongo_user} ${mongo_pass} --archive=${r_filename} ${mongo_auth_database}
exit_code=$? exit_code=$?
;; ;;
* ) * )