backup 971 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. # Exit on command errors and treat unset variables as an error
  3. set -eu
  4. # The parameter $1 is the backup directory location dedicated to the app
  5. backup_dir=$1
  6. # The parameter $2 is theid of the app instance
  7. app=$2
  8. # Source app helpers
  9. source /usr/share/yunohost/helpers
  10. domain=$(ynh_app_setting_get $app domain)
  11. final_path=$(ynh_app_setting_get $app final_path)
  12. # Copy the app files
  13. sudo mkdir -p ${backup_dir}/var/www
  14. sudo cp -a $final_path "${backup_dir}/var/www/$app"
  15. # Copy the conf files
  16. sudo mkdir -p "${backup_dir}/conf"
  17. sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf "${backup_dir}/conf/nginx.conf"
  18. # Copy dedicated php-fpm process to backup folder
  19. sudo cp -a /etc/php5/fpm/pool.d/$app.conf "${backup_dir}/conf/php-fpm.conf"
  20. sudo cp -a /etc/php5/fpm/conf.d/20-$app.ini "${backup_dir}/conf/php-fpm.ini"
  21. # Backup db
  22. root_pwd=$(sudo cat /etc/yunohost/mysql)
  23. sudo su -c "mysqldump -u root -p$root_pwd --no-create-db $app > ${backup_dir}/db.sql"