2015-12-26 14:14:31 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-01-28 18:51:23 +01:00
|
|
|
######## Actually we cant use common script in backup / restore script see this issue for more informations : https://dev.yunohost.org/issues/621
|
|
|
|
# # Import common cmd
|
|
|
|
# source ./_common.sh
|
|
|
|
#
|
2015-12-26 14:14:31 +01:00
|
|
|
|
2017-01-28 18:51:23 +01:00
|
|
|
######## We implement manually this fonctions
|
|
|
|
|
|
|
|
init_script() {
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
}
|
|
|
|
|
|
|
|
set_configuration() {
|
|
|
|
if [[ -e /var/www/$app ]]
|
|
|
|
then
|
|
|
|
final_path=/var/www/$app
|
|
|
|
seafile_user=www-data
|
|
|
|
elif [[ -e /opt/yunohost/$app ]]
|
|
|
|
then
|
|
|
|
final_path=/opt/yunohost/$app
|
|
|
|
seafile_user=seafile
|
|
|
|
else
|
|
|
|
ynh_die "Error : can't find seafile path"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
######## End of common fonctions
|
|
|
|
|
|
|
|
# Init script
|
|
|
|
init_script
|
2016-12-27 10:44:40 +01:00
|
|
|
|
|
|
|
# Set configuration for user and final path
|
|
|
|
set_configuration
|
|
|
|
|
2015-12-26 14:14:31 +01:00
|
|
|
# The parameter $1 is the backup directory location dedicated to the app
|
|
|
|
BACKUP_DIR=$1
|
|
|
|
|
|
|
|
# The parameter $2 is the id of the app instance ex: strut__2
|
2016-02-08 02:06:58 +01:00
|
|
|
APP=$2
|
2015-12-26 14:14:31 +01:00
|
|
|
|
|
|
|
# retrieve useful param
|
2016-12-27 10:44:40 +01:00
|
|
|
domain=$(ynh_app_setting_get ${APP} domain)
|
2017-01-31 23:25:17 +01:00
|
|
|
db_pwd=$(ynh_app_setting_get ${APP} mysqlpwd)
|
2015-12-26 14:14:31 +01:00
|
|
|
|
|
|
|
# Backup app files
|
|
|
|
sudo mkdir -p "${BACKUP_DIR}/www"
|
2016-12-27 10:44:40 +01:00
|
|
|
sudo cp -a $final_path/. "${BACKUP_DIR}/www"
|
2015-12-26 14:14:31 +01:00
|
|
|
|
|
|
|
# Backup conf files
|
|
|
|
sudo mkdir -p "${BACKUP_DIR}/conf"
|
2016-02-08 20:42:00 +01:00
|
|
|
sudo cp -a /etc/nginx/conf.d/$domain.d/${APP}.conf "${BACKUP_DIR}/conf/${APP}.conf"
|
2016-02-08 02:06:58 +01:00
|
|
|
sudo cp -a /etc/logrotate.d/${APP} "${BACKUP_DIR}/conf/${APP}"
|
2015-12-26 14:14:31 +01:00
|
|
|
sudo cp -a /etc/init.d/seafile-server "${BACKUP_DIR}/conf/seafile-server"
|
|
|
|
|
|
|
|
# Backup data
|
|
|
|
sudo mkdir -p "${BACKUP_DIR}/data"
|
|
|
|
sudo cp -a /home/yunohost.app/seafile-data/. "${BACKUP_DIR}/data"
|
|
|
|
|
|
|
|
# Backup mysql
|
2016-02-08 02:06:58 +01:00
|
|
|
mysqldump -u ${APP} -p$db_pwd ccnetdb | sudo dd of=${BACKUP_DIR}/ccnetdb.dmp
|
|
|
|
mysqldump -u ${APP} -p$db_pwd seafiledb | sudo dd of=${BACKUP_DIR}/seafiledb.dmp
|
2016-12-27 10:44:40 +01:00
|
|
|
mysqldump -u ${APP} -p$db_pwd seahubdb | sudo dd of=${BACKUP_DIR}/seahubdb.dmp
|