Skip to content

Commit 66265ac

Browse files
committed
restore: sqlite3: Fix restore failing when sqlite3 database already existed
1 parent ff8cc8c commit 66265ac

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

assets/runtime/functions

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,8 +800,10 @@ backup_restore_database() {
800800
;;
801801
sqlite3)
802802
echo "Restoring SQLite database..."
803-
gzip -dc "${config_default_backup_storage_path}/database.sql.gz" | \
804-
sqlite3 "${database_production_database}"
803+
exec_as_redmine mkdir -p "$(dirname "${database_production_database}")"
804+
# Remove old database
805+
exec_as_redmine rm -f "${database_production_database}"
806+
exec_as_redmine bash -lc "gzip -dc \"${config_default_backup_storage_path}/database.sql.gz\" | sqlite3 \"${database_production_database}\""
805807
;;
806808
*)
807809
echo "Database type ${database_production_adapter} not supported."

0 commit comments

Comments
 (0)