backup 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. ynh_clean_setup () {
  18. ### Remove this function if there's nothing to clean before calling the remove script.
  19. true
  20. }
  21. # Exit if an error occurs during the execution of the script
  22. ynh_abort_if_errors
  23. #=================================================
  24. # LOAD SETTINGS
  25. #=================================================
  26. app=$YNH_APP_INSTANCE_NAME
  27. final_path=$(ynh_app_setting_get $app final_path)
  28. domain=$(ynh_app_setting_get $app domain)
  29. db_name=$(ynh_app_setting_get $app db_name)
  30. #=================================================
  31. # STANDARD BACKUP STEPS
  32. #=================================================
  33. # BACKUP THE APP MAIN DIR
  34. #=================================================
  35. ynh_backup "$final_path"
  36. #=================================================
  37. # BACKUP THE NGINX CONFIGURATION
  38. #=================================================
  39. ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
  40. #=================================================
  41. # BACKUP THE PHP-FPM CONFIGURATION
  42. #=================================================
  43. ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
  44. ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini"
  45. #=================================================
  46. # BACKUP THE MYSQL DATABASE
  47. #=================================================
  48. ynh_mysql_dump_db "$db_name" > db.sql
  49. #=================================================
  50. # SPECIFIC BACKUP
  51. #=================================================
  52. # BACKUP LOGROTATE
  53. #=================================================
  54. ynh_backup "/etc/logrotate.d/$app"
  55. #=================================================
  56. # BACKUP SYSTEMD
  57. #=================================================
  58. ynh_backup "/etc/systemd/system/$app.service"
  59. #=================================================
  60. # BACKUP A CRON FILE
  61. #=================================================
  62. ynh_backup "/etc/cron.d/$app"