clean_backups 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. # RETRIEVE ARGUMENTS
  11. #=================================================
  12. ynh_script_progression --message="Retrieve arguments from the manifest"
  13. app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
  14. final_path=$(ynh_app_setting_get $app final_path)
  15. #=================================================
  16. # CHECK IF ARGUMENTS ARE CORRECT
  17. #=================================================
  18. #=================================================
  19. # CHECK IF AN ACTION HAS TO BE DONE
  20. #=================================================
  21. #=================================================
  22. # SPECIFIC ACTION
  23. #=================================================
  24. # CLEAN ALL BACKUP FILES
  25. #=================================================
  26. ynh_script_progression --message="Clean all backup files" --weight=9
  27. # Get the backup directory from the config file
  28. backup_dir="$(grep "^backup_dir=" "$final_path/Backup_list.conf" | cut -d= -f2)"
  29. while read directory <&3
  30. do
  31. if [ -n "$directory" ]
  32. then
  33. ynh_print_info "Clean backup directory $directory" >&2
  34. ynh_secure_remove "$directory"
  35. fi
  36. done 3<<< $(find "$backup_dir" -maxdepth 1 -mindepth 1 -type d)
  37. #=================================================
  38. # END OF SCRIPT
  39. #=================================================
  40. ynh_script_progression --message="Execution completed" --last