backup 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #=================================================
  22. # STANDARD BACKUP STEPS
  23. #=================================================
  24. # BACKUP THE APP MAIN DIR
  25. #=================================================
  26. ynh_print_info "Backing up the main app directory..."
  27. ynh_backup "$final_path"
  28. ynh_backup "/etc/sudoers.d/${app}_ynh"
  29. ynh_backup "/usr/local/bin/ipv6_expanded"
  30. ynh_backup "/usr/local/bin/ipv6_compressed"
  31. ynh_backup "/usr/local/bin/$service_name-loadcubefile.sh"
  32. ynh_backup "/etc/yunohost/hooks.d/90-vpnclient.tpl"
  33. ynh_backup "/etc/openvpn/client.conf.tpl"
  34. ynh_backup "/etc/openvpn/client.conf.tpl.restore"
  35. ynh_backup "/etc/openvpn/keys/"
  36. ynh_backup "/usr/local/bin/$service_name"
  37. ynh_backup "/usr/local/bin/$service_checker_name.sh"
  38. #=================================================
  39. # BACKUP THE NGINX CONFIGURATION
  40. #=================================================
  41. ynh_print_info "Backing up nginx web server configuration..."
  42. ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
  43. #=================================================
  44. # BACKUP THE PHP-FPM CONFIGURATION
  45. #=================================================
  46. ynh_print_info "Backing up php-fpm configuration..."
  47. ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
  48. #=================================================
  49. # SPECIFIC BACKUP
  50. #=================================================
  51. # BACKUP SYSTEMD
  52. #=================================================
  53. ynh_print_info "Backing up systemd configuration..."
  54. ynh_backup "/etc/systemd/system/$service_name.service"
  55. ynh_backup "/etc/systemd/system/$service_checker_name.service"
  56. ynh_backup "/etc/systemd/system/$service_checker_name.timer"
  57. ynh_backup "/etc/systemd/system/openvpn@.service"
  58. #=================================================
  59. # END OF SCRIPT
  60. #=================================================
  61. ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."