backup 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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_checker-loadcubefile.sh"
  34. ynh_backup "/etc/yunohost/hooks.d/post_iptable_rules/90-vpnclient"
  35. ynh_backup "/etc/yunohost/hooks.d/90-vpnclient"
  36. ynh_backup "/etc/openvpn/client.conf.tpl"
  37. ynh_backup "/etc/openvpn/client.conf.tpl.restore"
  38. ynh_backup "/etc/openvpn/keys/"
  39. ynh_backup "/usr/local/bin/$service_checker"
  40. ynh_backup "/usr/local/bin/$service_checker_name.sh"
  41. ynh_backup "/usr/local/bin/$service_checker_name.timer"
  42. #=================================================
  43. # BACKUP THE NGINX CONFIGURATION
  44. #=================================================
  45. ynh_print_info "Backing up nginx web server configuration..."
  46. ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
  47. #=================================================
  48. # BACKUP THE PHP-FPM CONFIGURATION
  49. #=================================================
  50. ynh_print_info "Backing up php-fpm configuration..."
  51. ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
  52. #=================================================
  53. # SPECIFIC BACKUP
  54. #=================================================
  55. # BACKUP SYSTEMD
  56. #=================================================
  57. ynh_print_info "Backing up systemd configuration..."
  58. ynh_backup "/etc/systemd/system/$service_name.service"
  59. ynh_backup "/etc/systemd/system/$service_checker_name.service"
  60. ynh_backup "/etc/systemd/system/openvpn@.service"
  61. #=================================================
  62. # END OF SCRIPT
  63. #=================================================
  64. ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."