restore 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. . /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. # If a MySQL database is used:
  23. #
  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. # Restore NGINX configuration
  31. sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
  32. # If a dedicated php-fpm process is used:
  33. #
  34. # # Copy PHP-FPM pool configuration and reload the service
  35. # sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf"
  36. # sudo service php5-fpm reload
  37. # Restart webserver
  38. sudo service nginx reload