backup 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC START
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. source ../settings/scripts/_common.sh
  8. source /usr/share/yunohost/helpers
  9. #=================================================
  10. # MANAGE SCRIPT FAILURE
  11. #=================================================
  12. # Exit if an error occurs during the execution of the script
  13. ynh_abort_if_errors
  14. #=================================================
  15. # LOAD SETTINGS
  16. #=================================================
  17. ynh_print_info "Loading installation settings..."
  18. app=$YNH_APP_INSTANCE_NAME
  19. final_path=$(ynh_app_setting_get $app final_path)
  20. domain=$(ynh_app_setting_get $app domain)
  21. service_name=$(ynh_app_setting_get $app service_name)
  22. service_checker_name=$service_name"-checker"
  23. #=================================================
  24. # STANDARD BACKUP STEPS
  25. #=================================================
  26. # BACKUP THE APP MAIN DIR
  27. #=================================================
  28. ynh_print_info "Backing up the main app directory..."
  29. ynh_backup "$final_path"
  30. ynh_backup "/etc/sudoers.d/${app}_ynh"
  31. ynh_backup "/usr/local/bin/ipv6_expanded"
  32. ynh_backup "/usr/local/bin/ipv6_compressed"
  33. ynh_backup "/usr/local/bin/$service_name-loadcubefile.sh"
  34. ynh_backup "/etc/yunohost/hooks.d/90-vpnclient"
  35. ynh_backup "/etc/openvpn/client.conf.tpl"
  36. ynh_backup "/etc/openvpn/client.conf.tpl.restore"
  37. ynh_backup "/etc/openvpn/keys/"
  38. ynh_backup "/usr/local/bin/$service_name"
  39. ynh_backup "/usr/local/bin/$service_checker_name.sh"
  40. ynh_backup "/usr/local/bin/$service_checker_name.timer"
  41. #=================================================
  42. # BACKUP THE NGINX CONFIGURATION
  43. #=================================================
  44. ynh_print_info "Backing up nginx web server configuration..."
  45. ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
  46. #=================================================
  47. # BACKUP THE PHP-FPM CONFIGURATION
  48. #=================================================
  49. ynh_print_info "Backing up php-fpm configuration..."
  50. ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
  51. #=================================================
  52. # SPECIFIC BACKUP
  53. #=================================================
  54. # BACKUP SYSTEMD
  55. #=================================================
  56. ynh_print_info "Backing up systemd configuration..."
  57. ynh_backup "/etc/systemd/system/$service_name.service"
  58. ynh_backup "/etc/systemd/system/$service_checker_name.service"
  59. ynh_backup "/etc/systemd/system/openvpn@.service"
  60. #=================================================
  61. # END OF SCRIPT
  62. #=================================================
  63. ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."