backup 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. # Exit if an error occurs during the execution of the script
  13. ynh_abort_if_errors
  14. #=================================================
  15. # LOAD SETTINGS
  16. #=================================================
  17. app=$YNH_APP_INSTANCE_NAME
  18. final_path=$(ynh_app_setting_get $app final_path)
  19. domain=$(ynh_app_setting_get $app domain)
  20. db_name=$(ynh_app_setting_get $app db_name)
  21. #=================================================
  22. # STANDARD BACKUP STEPS
  23. #=================================================
  24. # BACKUP THE APP MAIN DIR
  25. #=================================================
  26. ynh_backup "$final_path"
  27. #=================================================
  28. # BACKUP THE NGINX CONFIGURATION
  29. #=================================================
  30. ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
  31. #=================================================
  32. # BACKUP THE PHP-FPM CONFIGURATION
  33. #=================================================
  34. ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
  35. ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini"
  36. #=================================================
  37. # BACKUP THE MYSQL DATABASE
  38. #=================================================
  39. ynh_mysql_dump_db "$db_name" > db.sql
  40. #=================================================
  41. # SPECIFIC BACKUP
  42. #=================================================
  43. # BACKUP LOGROTATE
  44. #=================================================
  45. ynh_backup "/etc/logrotate.d/$app"
  46. #=================================================
  47. # BACKUP SYSTEMD
  48. #=================================================
  49. ynh_backup "/etc/systemd/system/$app.service"
  50. #=================================================
  51. # BACKUP THE CRON FILE
  52. #=================================================
  53. ynh_backup "/etc/cron.d/$app"