mirror of
https://github.com/YunoHost-Apps/coin_ynh.git
synced 2024-09-03 18:16:26 +02:00
Backup and restore database
This commit is contained in:
parent
1efb077f70
commit
f9bdeba4a5
3 changed files with 12 additions and 3 deletions
|
@ -18,3 +18,6 @@ ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
|||
|
||||
# Copy Gunicorn pool configuration
|
||||
ynh_backup "/etc/systemd/system/$app.service" "gunicorn.service"
|
||||
|
||||
# Backup database
|
||||
ynh_psql_dump_db "$app" > ${YNH_CWD}/dump.sql
|
||||
|
|
|
@ -7,9 +7,7 @@ function install_dependencies()
|
|||
|
||||
function init_db()
|
||||
{
|
||||
sed -i '/local\s*all\s*all\s*peer/i \
|
||||
local all coin password' /etc/postgresql/9.*/main/pg_hba.conf
|
||||
service postgresql reload
|
||||
ynh_psql_test_if_first_run
|
||||
# Generate random password
|
||||
db_name=$app
|
||||
db_user=$app
|
||||
|
|
|
@ -17,6 +17,7 @@ email=$(ynh_app_setting_get "$app" email)
|
|||
isp_name=$(ynh_app_setting_get "$app" isp_name)
|
||||
isp_site=$(ynh_app_setting_get "$app" isp_site)
|
||||
secret=$(ynh_app_setting_get "$app" secret)
|
||||
db_pwd=$(ynh_app_setting_get "$app" psqlpassword)
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl $domain$path -a $app \
|
||||
|
@ -61,6 +62,13 @@ if ynh_user_exists $admin; then
|
|||
sudo yunohost app addaccess $app -u $admin
|
||||
fi
|
||||
|
||||
# Restore database
|
||||
ynh_psql_test_if_first_run
|
||||
db_name=$app
|
||||
db_user=$app
|
||||
ynh_psql_create_db $db_name $db_user $db_pwd
|
||||
ynh_psql_execute_file_as_root "${YNH_CWD}/dump.sql" "$db_name"
|
||||
|
||||
# Log folder
|
||||
sudo mkdir -p /var/log/$app
|
||||
sudo chown -R $app /var/log/$app
|
||||
|
|
Loading…
Reference in a new issue