backup 834 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. # Exit on command errors and treat unset variables as an error
  3. set -eu
  4. # Get multi-instances specific variables
  5. app=$YNH_APP_INSTANCE_NAME
  6. # Source app helpers
  7. source /usr/share/yunohost/helpers
  8. # Retrieve app settings
  9. domain=$(ynh_app_setting_get "$app" domain)
  10. with_mysql=$(ynh_app_setting_get "$app" with_mysql)
  11. # Copy the app files
  12. final_path="/var/www/${app}"
  13. ynh_backup "$final_path" "sources" 1
  14. # Copy the nginx conf files
  15. ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
  16. # Copy the php-fpm conf files
  17. ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf"
  18. ynh_backup "/etc/php5/fpm/conf.d/20-${app}.ini" "php-fpm.ini"
  19. # Backup db
  20. if [[ $with_mysql -eq 1 ]]; then
  21. root_pwd=$(sudo cat /etc/yunohost/mysql)
  22. sudo su -c "mysqldump -u root -p$root_pwd --no-create-db $app > ./db.sql"
  23. fi