mirror of
https://github.com/YunoHost-Apps/transmission_ynh.git
synced 2024-09-04 01:46:12 +02:00
[enh] Add backup & restore script.
This commit is contained in:
parent
da76228184
commit
d16152c984
2 changed files with 100 additions and 0 deletions
25
scripts/backup
Normal file
25
scripts/backup
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Source YNH helpers
|
||||||
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# Get app instance name
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Retrieve arguments
|
||||||
|
domain=$(sudo yunohost app setting $app domain)
|
||||||
|
|
||||||
|
# Backup directory location for the app from where the script is executed and
|
||||||
|
# which will be compressed afterward
|
||||||
|
backup_dir=$YNH_APP_BACKUP_DIR
|
||||||
|
|
||||||
|
# Backup sources & data
|
||||||
|
ynh_backup "/home/yunohost.transmission" "data"
|
||||||
|
ynh_backup "/usr/share/transmission" "sources"
|
||||||
|
|
||||||
|
# Copy configuration files
|
||||||
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx.conf"
|
||||||
|
ynh_backup "/etc/transmission-daemon/settings.json" "conf/transmission.json"
|
75
scripts/restore
Normal file
75
scripts/restore
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Source YNH helpers
|
||||||
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# Get app instance name
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Retrieve arguments
|
||||||
|
domain=$(sudo yunohost app setting $app domain)
|
||||||
|
path=$(sudo yunohost app setting $app path)
|
||||||
|
|
||||||
|
# Check domain/path availability
|
||||||
|
sudo yunohost app checkurl $domain$path -a $app
|
||||||
|
if [[ ! $? -eq 0 ]]; then
|
||||||
|
echo "There is already an app on this URL : $domain$path" | sudo tee /dev/stderr
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
sources_path=/usr/share/transmission
|
||||||
|
if [ -d $sources_path ]; then
|
||||||
|
echo "There is already a directory: $sources_path " | sudo tee /dev/stderr
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
data_path=/home/yunohost.transmission
|
||||||
|
if [ -d $data_path ]; then
|
||||||
|
echo "There is already a directory: $data_path " | sudo tee /dev/stderr
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
nginx_conf=/etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
if [ -f $nginx_conf ]; then
|
||||||
|
echo "There is already a nginx conf file at this path: $nginx_conf " | sudo tee /dev/stderr
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
app_conf=/etc/transmission-daemon/settings.json
|
||||||
|
if [ -f $app_conf ]; then
|
||||||
|
echo "There is already a PHP-FPM conf file at this path: $app_conf " | sudo tee /dev/stderr
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Open port in firewall
|
||||||
|
sudo yunohost firewall allow TCP 51413 > /dev/null 2>&1
|
||||||
|
|
||||||
|
# Install official debian package
|
||||||
|
sudo apt-get install transmission-daemon -y -qq
|
||||||
|
|
||||||
|
# Make directories and set rights
|
||||||
|
sudo mkdir -p /home/yunohost.transmission/{progress,completed}
|
||||||
|
sudo chown -R debian-transmission:www-data /home/yunohost.transmission/
|
||||||
|
sudo chown -R debian-transmission:debian-transmission /home/yunohost.transmission/progress
|
||||||
|
sudo find /home/yunohost.transmission/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done
|
||||||
|
sudo find /home/yunohost.transmission/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done
|
||||||
|
|
||||||
|
# Reload transmission service
|
||||||
|
sudo service transmission-daemon reload
|
||||||
|
|
||||||
|
# Monitor service
|
||||||
|
sudo yunohost service add transmission-daemon
|
||||||
|
|
||||||
|
# Restore sources & data
|
||||||
|
sudo cp -a "./sources" $sources_path
|
||||||
|
sudo cp -a "./data" $data_path
|
||||||
|
|
||||||
|
# Restore conf files
|
||||||
|
sudo cp -a "./conf/nginx.conf" $nginx_conf
|
||||||
|
sudo cp -a "./conf/transmission.conf" $app_conf
|
||||||
|
|
||||||
|
# Reload Nginx
|
||||||
|
sudo service nginx reload
|
Loading…
Add table
Reference in a new issue