backup 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. db_name=$(ynh_app_setting_get --app=$app --key=db_name)
  26. phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
  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 NGINX CONFIGURATION
  33. #=================================================
  34. ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
  35. #=================================================
  36. # BACKUP THE PHP-FPM CONFIGURATION
  37. #=================================================
  38. ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
  39. #=================================================
  40. # BACKUP VARIOUS FILES
  41. #=================================================
  42. # Backup frontend config
  43. ynh_backup --src_path="/etc/zabbix/web"
  44. ynh_backup --src_path="/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
  45. # Backup server config
  46. ynh_backup --src_path="/etc/zabbix/zabbix_server.conf"
  47. # Backup agent config
  48. ynh_backup --src_path="/etc/zabbix/zabbix_agentd.conf"
  49. ynh_backup --src_path="/etc/zabbix/zabbix_agentd.d"
  50. # Backup sudo file
  51. ynh_backup --src_path="/etc/sudoers.d/zabbix"
  52. #=================================================
  53. # BACKUP THE MYSQL DATABASE
  54. #=================================================
  55. ynh_print_info --message="Backing up the MySQL database..."
  56. ynh_mysql_dump_db --database="$db_name" > db.sql
  57. #=================================================
  58. # END OF SCRIPT
  59. #=================================================
  60. ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."