backup 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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/php-fpm-$app.conf"
  43. ynh_backup --src_path="$fpm_config_dir/pool.d/$app.conf"
  44. #=================================================
  45. # SPECIFIC BACKUP
  46. #=================================================
  47. # BACKUP VARIOUS FILES
  48. #=================================================
  49. ynh_backup --src_path="$PI_HOLE_LOCAL_REPO"
  50. ynh_backup --src_path="$PI_HOLE_CONFIG_DIR"
  51. ynh_backup --src_path="$PI_HOLE_INSTALL_DIR"
  52. ynh_backup --src_path="/etc/cron.d/pihole"
  53. ynh_backup --src_path="$PI_HOLE_BIN_DIR/pihole"
  54. ynh_backup --src_path="/etc/bash_completion.d/pihole"
  55. ynh_backup --src_path="/etc/sudoers.d/pihole"
  56. ynh_backup --src_path="/etc/init.d/pihole-FTL"
  57. ynh_backup --src_path="/usr/bin/pihole-FTL"
  58. if test -e "/etc/dnsmasq.d/03-pihole-wildcard.conf"; then
  59. ynh_backup --src_path="/etc/dnsmasq.d/03-pihole-wildcard.conf"
  60. fi
  61. ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app"
  62. #=================================================
  63. # END OF SCRIPT
  64. #=================================================
  65. ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."