2
0

clean_backups 1.6 KB

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