From fb726795db6c7a6a789ef851edec3600dfdfd7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Mon, 4 May 2026 14:11:39 +0200 Subject: [PATCH] nextcloud/user_run: prompt to clean up leftover .bak folders before sync Before the sync loop, find all *.bak directories in the parent dirs of configured sync paths, list them with their size, and ask the user to delete them with a y/N prompt. Co-Authored-By: Claude Sonnet 4.6 --- .../0050_nextcloud_desktopclient/user_run.sh | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/client_software/0050_nextcloud_desktopclient/user_run.sh b/client_software/0050_nextcloud_desktopclient/user_run.sh index cc5a332..ecc4064 100755 --- a/client_software/0050_nextcloud_desktopclient/user_run.sh +++ b/client_software/0050_nextcloud_desktopclient/user_run.sh @@ -60,6 +60,29 @@ if [ "${#CLIENT_DATA_SYNC[@]}" -eq 0 ]; then exit 0 fi +#Check for leftover .bak directories from previous failed setups +_nc_bak_list=$( + for CLIENT_DATA_DECLARE_LINE in "${CLIENT_DATA_SYNC[@]}"; do + eval "${CLIENT_DATA_DECLARE_LINE}" + find "$(dirname "${CLIENT_DATA_SYNC_LINE[0]}")" -maxdepth 1 -type d -name "*.bak" 2>/dev/null + done | sort -u +) +if [ -n "${_nc_bak_list}" ]; then + echo "The following old backup folders were found and should be removed:" + echo "${_nc_bak_list}" | while IFS= read -r _nc_d; do + [ -n "${_nc_d}" ] && echo " $(du -sh "${_nc_d}" 2>/dev/null | cut -f1) ${_nc_d}" + done + read -r -p "Delete these backup folders? [y/N]: " _nc_del + if [ "${_nc_del}" = "y" ] || [ "${_nc_del}" = "Y" ]; then + echo "${_nc_bak_list}" | while IFS= read -r _nc_d; do + if [ -n "${_nc_d}" ]; then + rm -rf "${_nc_d}" + echo "Deleted: ${_nc_d}" + fi + done + fi +fi + #Loop through all Entries #_nc_first=1 _nc_wipe_done=0