mirror of
https://github.com/YunoHost-Apps/jupyterlab_ynh.git
synced 2024-09-03 19:26:35 +02:00
add backup and restore scripts
This commit is contained in:
parent
a269372aed
commit
c2a886f821
5 changed files with 172 additions and 2 deletions
|
@ -16,7 +16,7 @@
|
||||||
setup_private=1
|
setup_private=1
|
||||||
setup_public=1
|
setup_public=1
|
||||||
upgrade=1
|
upgrade=1
|
||||||
backup_restore=0
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=1
|
||||||
incorrect_path=1
|
incorrect_path=1
|
||||||
port_already_use=1
|
port_already_use=1
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "JupyterLab",
|
"name": "JupyterLab",
|
||||||
"id": "jupyterlab",
|
"id": "jupyterlab",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"version": "0.35.4~ynh2",
|
"version": "0.35.4~ynh3",
|
||||||
"description": {
|
"description": {
|
||||||
"en": "JupyterLab for Yunohost, an extensible environment for interactive and reproducible computing (notebook, terminal, text editor, file browser, rich outputs, etc.)",
|
"en": "JupyterLab for Yunohost, an extensible environment for interactive and reproducible computing (notebook, terminal, text editor, file browser, rich outputs, etc.)",
|
||||||
"fr": "JupyterLab pour YunoHost, un environnement informatique extensible, interactif et reproductible (bloc-notes, terminal, éditeur de texte, explorateur de fichiers, texte enrichi, etc.)"
|
"fr": "JupyterLab pour YunoHost, un environnement informatique extensible, interactif et reproductible (bloc-notes, terminal, éditeur de texte, explorateur de fichiers, texte enrichi, etc.)"
|
||||||
|
|
64
scripts/backup
Normal file
64
scripts/backup
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Source YunoHost helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# Load common variables and helpers
|
||||||
|
source ../settings/scripts/_common.sh
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup() {
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Copy NGINX configuration
|
||||||
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD BACKUP STEPS
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP JUPYTERLAB
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info "Backuping of JupyterLab..."
|
||||||
|
|
||||||
|
ynh_backup "$final_path/jupyterhub.sqlite"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP CONF FILES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info "Backuping configuration files of JupyterLab..."
|
||||||
|
|
||||||
|
ynh_backup "$config_path/jupyterhub_config.py"
|
||||||
|
ynh_backup "$final_path/etc/jupyter/jupyter_notebook_config.py"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup "/etc/systemd/system/$app.service"
|
||||||
|
|
104
scripts/restore
Normal file
104
scripts/restore
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Source YunoHost helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
if [ ! -e _common.sh ]; then
|
||||||
|
# Get the _common.sh file if it's not in the current directory
|
||||||
|
cp ../settings/scripts/_common.sh ./_common.sh
|
||||||
|
mkdir ./upgrade.d
|
||||||
|
mkdir ../conf
|
||||||
|
cp ../settings/scripts/upgrade.d/*.sh ./upgrade.d/*.sh
|
||||||
|
cp ../settings/conf/*.default ../conf/
|
||||||
|
chmod a+rx _common.sh upgrade.d/*.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Load common variables and helpers
|
||||||
|
source _common.sh
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup() {
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Copy NGINX configuration
|
||||||
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
path_url=$(ynh_app_setting_get "$app" path_url)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_webpath_available $domain $path_url ||
|
||||||
|
ynh_die "Path not available: ${domain}${path_url}"
|
||||||
|
test ! -d $final_path ||
|
||||||
|
ynh_die "There is already a directory: $final_path "
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD RESTORATION STEPS
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REINSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_install_app_dependencies openssh-server
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE CONF FILES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info "Restoring configuration files of JupyerLab..."
|
||||||
|
|
||||||
|
ynh_backup "$config_path/jupyterhub_config.py"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info "Restoring JupyterLab..."
|
||||||
|
|
||||||
|
setup_source $architecture
|
||||||
|
|
||||||
|
ynh_backup "$final_path/etc/jupyter/jupyter_notebook_config.py"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC RESTORATION
|
||||||
|
#=================================================
|
||||||
|
# RESTORE SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_restore_file "/etc/systemd/system/$app.service"
|
||||||
|
|
||||||
|
yunohost service add $app --log "/var/log/$app/APP.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
systemctl reload nginx
|
||||||
|
|
||||||
|
ynh_systemd_action -n $app -a start -l "JupyterHub is now running at" -p "systemd"
|
|
@ -82,6 +82,8 @@ setup_source $miniconda_architecture
|
||||||
jupyter labextension install @jupyterlab/hub-extension
|
jupyter labextension install @jupyterlab/hub-extension
|
||||||
jupyter lab build
|
jupyter lab build
|
||||||
|
|
||||||
|
jupyterhub upgrade-db
|
||||||
|
|
||||||
chown $admin -R $final_path/share/jupyter
|
chown $admin -R $final_path/share/jupyter
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue