2
0

clean_backups 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 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. # Get the backup directory from the config file
  26. backup_dir="$(grep "^backup_dir=" "$final_path/Backup_list.conf" | cut -d= -f2)"
  27. while read directory <&3
  28. do
  29. if [ -n "$directory" ]
  30. then
  31. ynh_print_info "Clean backup directory $directory" >&2
  32. ynh_secure_remove "$directory"
  33. fi
  34. done 3<<< $(find "$backup_dir" -maxdepth 1 -mindepth 1 -type d)