backup 2.8 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.tpl"
  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. #=================================================
  41. # BACKUP THE NGINX CONFIGURATION
  42. #=================================================
  43. ynh_print_info "Backing up nginx web server configuration..."
  44. ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
  45. #=================================================
  46. # BACKUP THE PHP-FPM CONFIGURATION
  47. #=================================================
  48. ynh_print_info "Backing up php-fpm configuration..."
  49. ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
  50. #=================================================
  51. # SPECIFIC BACKUP
  52. #=================================================
  53. # BACKUP SYSTEMD
  54. #=================================================
  55. ynh_print_info "Backing up systemd configuration..."
  56. ynh_backup "/etc/systemd/system/$service_name.service"
  57. ynh_backup "/etc/systemd/system/$service_checker_name.service"
  58. ynh_backup "/etc/systemd/system/$service_checker_name.timer"
  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)."