backup 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. for FILE in $(ls /etc/openvpn/scripts/route-up.d/*-vpnclient-* /etc/openvpn/scripts/route-down.d/*-vpnclient-*); do
  32. ynh_backup --src_path="$FILE"
  33. done
  34. ynh_backup --src_path="/etc/openvpn/keys/"
  35. ynh_backup --src_path="/etc/openvpn/scripts/run-parts.sh"
  36. ynh_backup --src_path="/usr/local/bin/$service_name"
  37. ynh_backup --src_path="/usr/local/bin/$service_checker_name.sh"
  38. #=================================================
  39. # SPECIFIC BACKUP
  40. #=================================================
  41. # BACKUP SYSTEMD
  42. #=================================================
  43. ynh_print_info "Backing up systemd configuration..."
  44. ynh_backup --src_path="/etc/systemd/system/$service_name.service"
  45. ynh_backup --src_path="/etc/systemd/system/$service_checker_name.service"
  46. ynh_backup --src_path="/etc/systemd/system/$service_checker_name.timer"
  47. ynh_backup --src_path="/etc/systemd/system/openvpn@.service.d/override.conf"
  48. #=================================================
  49. # END OF SCRIPT
  50. #=================================================
  51. ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."