backup 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #=================================================
  20. # STANDARD BACKUP STEPS
  21. #=================================================
  22. # BACKUP THE APP MAIN DIR
  23. #=================================================
  24. ynh_print_info "Backing up the main app directory..."
  25. ynh_backup --src_path="/usr/local/bin/$service_name-loadcubefile.sh"
  26. ynh_backup --src_path="/etc/yunohost/hooks.d/90-vpnclient.tpl"
  27. ynh_backup --src_path="/etc/openvpn/client.conf.tpl"
  28. ynh_backup --src_path="/etc/openvpn/client.conf" --not_mandatory
  29. ynh_backup --src_path="/etc/openvpn/client.cube" --not_mandatory
  30. ynh_backup --src_path="/etc/openvpn/client.ovpn" --not_mandatory
  31. ynh_backup --src_path="/etc/openvpn/scripts/route-up.d/20-set-ipv6"
  32. ynh_backup --src_path="/etc/openvpn/scripts/route-up.d/20-set-server-ipv6-route"
  33. ynh_backup --src_path="/etc/openvpn/scripts/route-up.d/30-set-dns"
  34. ynh_backup --src_path="/etc/openvpn/scripts/route-up.d/30-set-firewall"
  35. ynh_backup --src_path="/etc/openvpn/scripts/route-up.d/99-validate"
  36. ynh_backup --src_path="/etc/openvpn/scripts/route-down.d/20-unset-ipv6"
  37. ynh_backup --src_path="/etc/openvpn/scripts/route-down.d/20-unset-server-ipv6-route"
  38. ynh_backup --src_path="/etc/openvpn/scripts/route-down.d/30-unset-dns"
  39. ynh_backup --src_path="/etc/openvpn/scripts/route-down.d/30-unset-firewall"
  40. ynh_backup --src_path="/etc/openvpn/keys/"
  41. ynh_backup --src_path="/etc/openvpn/scripts/run-parts.sh"
  42. ynh_backup --src_path="/usr/local/bin/$service_name"
  43. ynh_backup --src_path="/usr/local/bin/$service_checker_name.sh"
  44. #=================================================
  45. # SPECIFIC BACKUP
  46. #=================================================
  47. # BACKUP SYSTEMD
  48. #=================================================
  49. ynh_print_info "Backing up systemd configuration..."
  50. ynh_backup --src_path="/etc/systemd/system/$service_name.service"
  51. ynh_backup --src_path="/etc/systemd/system/$service_checker_name.service"
  52. ynh_backup --src_path="/etc/systemd/system/$service_checker_name.timer"
  53. ynh_backup --src_path="/etc/systemd/system/openvpn@.service.d/override.conf"
  54. #=================================================
  55. # END OF SCRIPT
  56. #=================================================
  57. ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."