backup 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. # Exit if an error occurs during the execution of the script
  14. ynh_abort_if_errors
  15. #=================================================
  16. # LOAD SETTINGS
  17. #=================================================
  18. ynh_print_info --message="Loading installation settings..."
  19. app=$YNH_APP_INSTANCE_NAME
  20. final_path=$(ynh_app_setting_get --app=$app --key=final_path)
  21. domain=$(ynh_app_setting_get --app=$app --key=domain)
  22. db_name=$(ynh_app_setting_get --app=$app --key=db_name)
  23. phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
  24. #=================================================
  25. # DECLARE DATA AND CONF FILES TO BACKUP
  26. #=================================================
  27. ynh_print_info --message="Declaring files to be backed up..."
  28. #=================================================
  29. # BACKUP THE APP MAIN DIR
  30. #=================================================
  31. ynh_backup --src_path="$final_path"
  32. #=================================================
  33. # BACKUP THE NGINX CONFIGURATION
  34. #=================================================
  35. ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
  36. #=================================================
  37. # BACKUP THE PHP-FPM CONFIGURATION
  38. #=================================================
  39. ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
  40. #=================================================
  41. # BACKUP THE MYSQL DATABASE
  42. #=================================================
  43. ynh_print_info --message="Backing up the MySQL database..."
  44. ynh_mysql_dump_db --database="$db_name" > db.sql
  45. #=================================================
  46. # END OF SCRIPT
  47. #=================================================
  48. ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."