backup 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. ynh_clean_setup () {
  13. ### Remove this function if there's nothing to clean before calling the remove script.
  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 "Loading installation settings..."
  22. app=$YNH_APP_INSTANCE_NAME
  23. final_path=$(ynh_app_setting_get $app final_path)
  24. domain=$(ynh_app_setting_get $app domain)
  25. db_name=$(ynh_app_setting_get $app db_name)
  26. #=================================================
  27. # STANDARD BACKUP STEPS
  28. #=================================================
  29. # BACKUP THE APP MAIN DIR
  30. #=================================================
  31. ynh_print_info "Backing up the main app directory..."
  32. ynh_backup "$final_path"
  33. #=================================================
  34. # BACKUP THE NGINX CONFIGURATION
  35. #=================================================
  36. ynh_print_info "Backing up nginx web server configuration..."
  37. ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
  38. #=================================================
  39. # BACKUP THE PHP-FPM CONFIGURATION
  40. #=================================================
  41. ynh_print_info "Backing up php-fpm configuration..."
  42. ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
  43. #=================================================
  44. # BACKUP THE MYSQL DATABASE
  45. #=================================================
  46. ynh_print_info "Backing up the MySQL database..."
  47. ynh_mysql_dump_db "$db_name" > db.sql
  48. #=================================================
  49. # SPECIFIC BACKUP
  50. #=================================================
  51. # BACKUP LOGROTATE
  52. #=================================================
  53. ynh_print_info "Backing up logrotate configuration..."
  54. ynh_backup "/etc/logrotate.d/$app"
  55. #=================================================
  56. # BACKUP SYSTEMD
  57. #=================================================
  58. ynh_print_info "Backing up systemd configuration..."
  59. ynh_backup "/etc/systemd/system/$app.service"
  60. #=================================================
  61. # BACKUP A CRON FILE
  62. #=================================================
  63. ynh_backup "/etc/cron.d/$app"
  64. #=================================================
  65. # END OF SCRIPT
  66. #=================================================
  67. ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."