backup 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC START
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
  8. source ../settings/scripts/_common.sh
  9. source /usr/share/yunohost/helpers
  10. #=================================================
  11. # MANAGE SCRIPT FAILURE
  12. #=================================================
  13. ynh_clean_setup () {
  14. true
  15. }
  16. # Exit if an error occurs during the execution of the script
  17. ynh_abort_if_errors
  18. #=================================================
  19. # LOAD SETTINGS
  20. #=================================================
  21. ynh_print_info --message="Loading installation settings..."
  22. app=$YNH_APP_INSTANCE_NAME
  23. final_path=$(ynh_app_setting_get --app=$app --key=final_path)
  24. domain=$(ynh_app_setting_get --app=$app --key=domain)
  25. # Get variable from ynh_add_fpm_config
  26. fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
  27. #=================================================
  28. # DECLARE DATA AND CONF FILES TO BACKUP
  29. #=================================================
  30. ynh_print_info --message="Declaring files to be backed up..."
  31. #=================================================
  32. # BACKUP THE APP MAIN DIR
  33. #=================================================
  34. ynh_backup --src_path="$final_path"
  35. #=================================================
  36. # BACKUP THE NGINX CONFIGURATION
  37. #=================================================
  38. ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
  39. #=================================================
  40. # BACKUP THE PHP-FPM CONFIGURATION
  41. #=================================================
  42. ynh_backup --src_path="$fpm_config_dir/pool.d/$app.conf"
  43. #=================================================
  44. # SPECIFIC BACKUP
  45. #=================================================
  46. # BACKUP VARIOUS FILES
  47. #=================================================
  48. ynh_backup --src_path="$PI_HOLE_LOCAL_REPO"
  49. ynh_backup --src_path="$PI_HOLE_CONFIG_DIR"
  50. ynh_backup --src_path="$PI_HOLE_INSTALL_DIR"
  51. ynh_backup --src_path="/etc/cron.d/pihole"
  52. ynh_backup --src_path="$PI_HOLE_BIN_DIR/pihole"
  53. ynh_backup --src_path="/etc/bash_completion.d/pihole"
  54. ynh_backup --src_path="/etc/sudoers.d/pihole"
  55. ynh_backup --src_path="/etc/init.d/pihole-FTL"
  56. ynh_backup --src_path="/usr/bin/pihole-FTL"
  57. if test -e "/etc/dnsmasq.d/03-pihole-wildcard.conf"; then
  58. ynh_backup --src_path="/etc/dnsmasq.d/03-pihole-wildcard.conf"
  59. fi
  60. ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app"
  61. #=================================================
  62. # END OF SCRIPT
  63. #=================================================
  64. ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."