mirror of
https://github.com/YunoHost-Apps/minetest_ynh.git
synced 2024-09-03 20:36:00 +02:00
Add backup and restore scripts
This commit is contained in:
parent
1abced33e6
commit
9d68f09bfc
4 changed files with 125 additions and 1 deletions
61
scripts/backup
Executable file
61
scripts/backup
Executable file
|
@ -0,0 +1,61 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Exit on command errors and treat unset variables as an error
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC STARTING
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if [ ! -e _common.sh ]; then
|
||||||
|
# Get the functions file if not present in the current directory
|
||||||
|
sudo cp ../settings/scripts/_common.sh ./_common.sh
|
||||||
|
sudo chmod a+rx _common.sh
|
||||||
|
fi
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
pvp=$(ynh_app_setting_get $app pvp)
|
||||||
|
damage=$(ynh_app_setting_get $app damage)
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
creative=$(ynh_app_setting_get $app creative)
|
||||||
|
is_public=$(ynh_app_setting_get $app is_public)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP STEPS
|
||||||
|
#=================================================
|
||||||
|
# CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
CHECK_SIZE "/etc/minetest.conf"
|
||||||
|
ynh_backup "/etc/minetest.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DATA
|
||||||
|
#=================================================
|
||||||
|
CHECK_SIZE "/var/games/minetest-server/"
|
||||||
|
ynh_backup "/var/games/minetest-server/"
|
||||||
|
|
||||||
|
echo ".backup /tmp/map.sqlite" | sqlite3 /var/games/minetest-server/.minetest/worlds/world
|
||||||
|
CHECK_SIZE "/tmp/map.sqlite"
|
||||||
|
ynh_backup "/tmp/map.sqlite"
|
||||||
|
ynh_secure_remove "/tmp/map.sqlite"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP OF APT PREFERENCES AND SOURCES.LIST
|
||||||
|
#=================================================
|
||||||
|
CHECK_SIZE "/etc/apt/sources.list.d/$app.list"
|
||||||
|
ynh_backup "/etc/apt/sources.list.d/$app.list"
|
||||||
|
|
||||||
|
CHECK_SIZE "/etc/apt/preferences.d/00MinetestPinning"
|
||||||
|
ynh_backup "/etc/apt/preferences.d/00MinetestPinning"
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
ynh_package_update
|
ynh_package_update
|
||||||
ynh_install_app_dependencies minetest-server
|
ynh_install_app_dependencies minetest-server sqlite3
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENABLE SERVICE IN ADMIN PANEL
|
# ENABLE SERVICE IN ADMIN PANEL
|
||||||
|
|
63
scripts/restore
Executable file
63
scripts/restore
Executable file
|
@ -0,0 +1,63 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Exit on command errors and treat unset variables as an error
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC STARTING
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if [ ! -e _common.sh ]; then
|
||||||
|
# Get the functions file if not present in the current directory
|
||||||
|
sudo cp ../settings/scripts/_common.sh ./_common.sh
|
||||||
|
sudo chmod a+rx _common.sh
|
||||||
|
fi
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
pvp=$(ynh_app_setting_get $app pvp)
|
||||||
|
damage=$(ynh_app_setting_get $app damage)
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
creative=$(ynh_app_setting_get $app creative)
|
||||||
|
is_public=$(ynh_app_setting_get $app is_public)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP STEPS
|
||||||
|
#=================================================
|
||||||
|
# STOP SERVICE
|
||||||
|
#=================================================
|
||||||
|
service minetest stop
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_restore_file "/etc/minetest.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DATA
|
||||||
|
#=================================================
|
||||||
|
ynh_restore_file "/var/games/minetest-server/"
|
||||||
|
|
||||||
|
ynh_restore_file "/tmp/map.sqlite"
|
||||||
|
echo ".restore /tmp/map.sqlite" | sqlite3 /var/games/minetest-server/.minetest/worlds/world
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP OF APT PREFERENCES AND SOURCES.LIST
|
||||||
|
#=================================================
|
||||||
|
ynh_restore_file "/etc/apt/sources.list.d/$app.list"
|
||||||
|
|
||||||
|
ynh_restore_file "/etc/apt/preferences.d/00MinetestPinning"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START SERVICE
|
||||||
|
#=================================================
|
||||||
|
service minetest start
|
0
scripts/upgrade
Normal file → Executable file
0
scripts/upgrade
Normal file → Executable file
Loading…
Add table
Reference in a new issue