Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
freedombone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Context Sensitive Group
freedombone
Commits
604a1929
Commit
604a1929
authored
7 years ago
by
Bob Mottram
Browse files
Options
Downloads
Patches
Plain Diff
Improve restore of mariadb
parent
45be6e29
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/freedombone-pass
+1
-1
1 addition, 1 deletion
src/freedombone-pass
src/freedombone-restore-local
+20
-9
20 additions, 9 deletions
src/freedombone-restore-local
with
21 additions
and
10 deletions
src/freedombone-pass
+
1
−
1
View file @
604a1929
...
...
@@ -22,7 +22,7 @@
# License
# =======
#
# Copyright (C) 2016 Bob Mottram <bob@freedombone.net>
# Copyright (C) 2016
-2017
Bob Mottram <bob@freedombone.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
...
...
This diff is collapsed.
Click to expand it.
src/freedombone-restore-local
+
20
−
9
View file @
604a1929
...
...
@@ -83,9 +83,6 @@ if [ -f $COMPLETION_FILE ]; then
ADMIN_USERNAME
=
$(
get_completion_param
"Admin user"
)
fi
# MariaDB password
DATABASE_PASSWORD
=
$(
${
PROJECT_NAME
}
-pass
-u
root
-a
mariadb
)
function
check_backup_exists
{
if
[
!
-d
$USB_MOUNT
/backup
]
;
then
echo
$"No backup directory found on the USB drive."
...
...
@@ -209,13 +206,17 @@ function restore_mariadb {
keep_database_running
temp_restore_dir
=
/root/tempmariadb
restore_directory_from_usb
$temp_restore_dir
mariadb
echo
$'Obtaining MariaDB password'
db_pass
=
$(
${
PROJECT_NAME
}
-pass
-u
root
-a
mariadb
)
store_original_mariadb_password
echo
$'Obtaining original MariaDB password'
db_pass
=
$(
cat
/root/.mariadboriginal
)
if
[
${#
db_pass
}
-gt
0
]
;
then
echo
$"Restore the MariaDB user table"
mysqlsuccess
=
$(
mysql
-u
root
--password
=
"
$
DATABASE_PASSWORD
"
mysql
-o
<
${
temp_restore_dir
}${
temp_restore_dir
}
/mysql.sql
)
mysqlsuccess
=
$(
mysql
-u
root
--password
=
"
$
db_pass
"
mysql
-o
<
${
temp_restore_dir
}${
temp_restore_dir
}
/mysql.sql
)
if
[
!
"
$?
"
=
"0"
]
;
then
echo
$"Try again using the password obtained from backup"
db_pass
=
$(
${
PROJECT_NAME
}
-pass
-u
root
-a
mariadb
)
mysqlsuccess
=
$(
mysql
-u
root
--password
=
"
$db_pass
"
mysql
-o
<
${
temp_restore_dir
}${
temp_restore_dir
}
/mysql.sql
)
fi
if
[
!
"
$?
"
=
"0"
]
;
then
...
...
@@ -226,9 +227,9 @@ function restore_mariadb {
fi
echo
$"Restarting database"
systemctl restart mariadb
echo
$"
Change th
e MariaDB
password to the backup vers
ion"
DATABASE
_PASSWORD
=
"
$db_pass
"
${
PROJECT_NAME
}
-pass
-u
root
-a
mariadb
-p
"
$DATABASE_PASSWORD
"
echo
$"
Ensur
e MariaDB
handles authenticat
ion"
MARIADB
_PASSWORD
=
$(
${
PROJECT_NAME
}
-pass
-u
root
-a
mariadb
)
mariadb_fix_authentication
fi
rm
-rf
$temp_restore_dir
fi
...
...
@@ -248,6 +249,15 @@ function restore_letsencrypt {
fi
}
function
store_original_mariadb_password
{
if
[
!
-f
/root/.mariadboriginal
]
;
then
echo
$'Storing original mariadb password'
ORIGINAL_MARIADB_PASSWORD
=
$(
${
PROJECT_NAME
}
-pass
-u
root
-a
mariadb
)
# We can store this in plaintext because it will soon be of historical interest only
echo
-n
"
$ORIGINAL_MARIADB_PASSWORD
"
>
/root/.mariadboriginal
fi
}
function
restore_passwordstore
{
if
[[
$RESTORE_APP
!=
'all'
]]
;
then
if
[[
$RESTORE_APP
!=
'passwords'
]]
;
then
...
...
@@ -255,6 +265,7 @@ function restore_passwordstore {
fi
fi
if
[
-d
$USB_MOUNT
/backup/passwordstore
]
;
then
store_original_mariadb_password
echo
$"Restoring password store"
restore_directory_from_usb / passwordstore
fi
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment