backup 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_script_progression --message="Loading installation settings..." --weight=2
  18. app=$YNH_APP_INSTANCE_NAME
  19. final_path=$(ynh_app_setting_get --app=$app --key=final_path)
  20. path_url=$(ynh_app_setting_get --app=$app --key=path)
  21. domain=$(ynh_app_setting_get --app=$app --key=domain)
  22. # Get variable from ynh_add_fpm_config
  23. fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
  24. #=================================================
  25. # STANDARD BACKUP STEPS
  26. #=================================================
  27. # BACKUP THE MAIN APP DIRECTORIES
  28. #=================================================
  29. ynh_script_progression --message="Backing up the main app directory..." --weight=5
  30. ynh_backup --src_path="$final_path"
  31. ynh_backup --src_path="/etc/.pihole"
  32. ynh_backup --src_path="/etc/pihole"
  33. ynh_backup --src_path="/opt/pihole"
  34. #=================================================
  35. # BACKUP NGINX CONFIGURATION
  36. #=================================================
  37. ynh_script_progression --message="Backing up nginx web server configuration..."
  38. ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
  39. #=================================================
  40. # BACKUP PHP-FPM CONFIGURATION
  41. #=================================================
  42. ynh_script_progression --message="Backing up php-fpm configuration..."
  43. ynh_backup --src_path="$fpm_config_dir/php-fpm-$app.conf"
  44. ynh_backup --src_path="$fpm_config_dir/pool.d/$app.conf"
  45. #=================================================
  46. # SPECIFIC BACKUP
  47. #=================================================
  48. # BACKUP CRON FILE
  49. #=================================================
  50. ynh_script_progression --message="Backing up cron file..."
  51. ynh_backup --src_path="/etc/cron.d/pihole"
  52. #=================================================
  53. # BACKUP SPECIFIC FILES
  54. #=================================================
  55. ynh_script_progression --message="Backing specific files..."
  56. ynh_backup --src_path="/usr/local/bin/pihole"
  57. ynh_backup --src_path="/etc/bash_completion.d/pihole"
  58. ynh_backup --src_path="/etc/sudoers.d/pihole"
  59. ynh_backup --src_path="/etc/init.d/pihole-FTL"
  60. ynh_backup --src_path="/usr/bin/pihole-FTL"
  61. ynh_backup --src_path="/etc/dnsmasq.d/01-pihole.conf"
  62. if test -e "/etc/dnsmasq.d/02-pihole-dhcp.conf"; then
  63. ynh_backup --src_path="/etc/dnsmasq.d/02-pihole-dhcp.conf"
  64. fi
  65. if test -e "/etc/dnsmasq.d/03-pihole-wildcard.conf"; then
  66. ynh_backup --src_path="/etc/dnsmasq.d/03-pihole-wildcard.conf"
  67. fi
  68. if test -e "/etc/dnsmasq.d/04-pihole-static-dhcp.conf"; then
  69. ynh_backup --src_path="/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
  70. fi
  71. ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app"
  72. #=================================================
  73. # END OF SCRIPT
  74. #=================================================
  75. ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last