restore 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. # Note: each files and directories you've saved using the ynh_backup helper
  3. # will be located in the current directory, regarding the last argument.
  4. # Exit on command errors and treat unset variables as an error
  5. set -eu
  6. # See comments in install script
  7. app=$YNH_APP_INSTANCE_NAME
  8. # Source YunoHost helpers
  9. source /usr/share/yunohost/helpers
  10. # Retrieve old app settings
  11. domain=$(ynh_app_setting_get "$app" domain)
  12. path=$(ynh_app_setting_get "$app" path)
  13. # Check domain/path availability
  14. sudo yunohost app checkurl "${domain}${path}" -a "$app" \
  15. || ynh_die "Path not available: ${domain}${path}"
  16. # Restore sources & data
  17. src_path="/var/www/${app}"
  18. sudo cp -a ./sources "$src_path"
  19. # Restore permissions to app files
  20. # you may need to make some file and/or directory writeable by www-data (nginx user)
  21. sudo chown -R root: "$src_path"
  22. ### MySQL (remove if not used) ###
  23. # If a MySQL database is used:
  24. # # Create and restore the database
  25. # dbname=$app
  26. # dbuser=$app
  27. # dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
  28. # ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
  29. # ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql
  30. ### MySQL end ###
  31. # Restore NGINX configuration
  32. sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
  33. ### PHP (remove if not used) ###
  34. # If a dedicated php-fpm process is used:
  35. # # Copy PHP-FPM pool configuration and reload the service
  36. # sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf"
  37. # sudo service php5-fpm reload
  38. ### PHP end ###
  39. # Restart webserver
  40. sudo service nginx reload