backup 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC START
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. if [ ! -e _common.sh ]; then
  8. # Get the _common.sh file if it's not in the current directory
  9. cp ../settings/scripts/_common.sh ./_common.sh
  10. chmod a+rx _common.sh
  11. fi
  12. source _common.sh
  13. source /usr/share/yunohost/helpers
  14. #=================================================
  15. # MANAGE SCRIPT FAILURE
  16. #=================================================
  17. # Exit if an error occurs during the execution of the script
  18. ynh_abort_if_errors
  19. #=================================================
  20. # LOAD SETTINGS
  21. #=================================================
  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_backup "$final_path"
  32. #=================================================
  33. # BACKUP THE NGINX CONFIGURATION
  34. #=================================================
  35. ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
  36. #=================================================
  37. # BACKUP THE PHP-FPM CONFIGURATION
  38. #=================================================
  39. ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
  40. ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini"
  41. #=================================================
  42. # BACKUP THE MYSQL DATABASE
  43. #=================================================
  44. ynh_mysql_dump_db "$db_name" > db.sql
  45. #=================================================
  46. # SPECIFIC BACKUP
  47. #=================================================
  48. # BACKUP LOGROTATE
  49. #=================================================
  50. ynh_backup "/etc/logrotate.d/$app"
  51. #=================================================
  52. # BACKUP SYSTEMD
  53. #=================================================
  54. ynh_backup "/etc/systemd/system/$app.service"
  55. #=================================================
  56. # BACKUP THE CRON FILE
  57. #=================================================
  58. ynh_backup "/etc/cron.d/$app"