backup 949 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. # causes the shell to exit if any subcommand or pipeline returns a non-zero status
  3. set -e
  4. # The last argument is the app instance name
  5. app=${!#}
  6. # The first argument is the backup directory location for the app
  7. # from where the script is executed and which will be compressed afterward
  8. backup_dir=$1
  9. # Backup sources & data
  10. sudo cp -a /var/www/$app/. $backup_dir/sources
  11. # Backup mysql database if needed
  12. # db_pwd=$(sudo yunohost app setting $app mysqlpwd)
  13. # sudo mysqldump -u $app -p$db_pwd $app > $backup_dir/$app.dmp
  14. # Copy Nginx and YunoHost parameters to make the script "standalone"
  15. sudo cp -a /etc/yunohost/apps/$app/. $backup_dir/yunohost
  16. domain=$(sudo yunohost app setting $app domain)
  17. sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $backup_dir/nginx.conf
  18. # If a dedicated php-fpm process is used :
  19. # Copy dedicated php-fpm process to backup folder
  20. #
  21. #sudo cp -a /etc/php5/fpm/pool.d/$app.conf $backup_dir/php-fpm.conf