2
0

clean_backups 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC STARTING
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. source 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. # RETRIEVE ARGUMENTS
  16. #=================================================
  17. app=$YNH_APP_INSTANCE_NAME
  18. final_path=$(ynh_app_setting_get --app=$app --key=final_path)
  19. #=================================================
  20. # CHECK IF ARGUMENTS ARE CORRECT
  21. #=================================================
  22. #=================================================
  23. # CHECK IF AN ACTION HAS TO BE DONE
  24. #=================================================
  25. #=================================================
  26. # SPECIFIC ACTION
  27. #=================================================
  28. # CLEAN ALL BACKUP FILES
  29. #=================================================
  30. ynh_script_progression --message="Cleaning all backup files..." --weight=9
  31. # Get the backup directory from the config file
  32. backup_dir="$(grep "^backup_dir=" "$final_path/Backup_list.conf" | cut -d= -f2)"
  33. while read directory <&3
  34. do
  35. if [ -n "$directory" ]
  36. then
  37. ynh_print_info --message="Clean backup directory $directory"
  38. ynh_secure_remove --file="$directory"
  39. fi
  40. done 3<<< $(find "$backup_dir" -maxdepth 1 -mindepth 1 -type d)
  41. #=================================================
  42. # END OF SCRIPT
  43. #=================================================
  44. ynh_script_progression --message="Execution completed" --last