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 <noreply@anthropic.com>
This commit is contained in:
@@ -60,6 +60,29 @@ if [ "${#CLIENT_DATA_SYNC[@]}" -eq 0 ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
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
|
#Loop through all Entries
|
||||||
#_nc_first=1
|
#_nc_first=1
|
||||||
_nc_wipe_done=0
|
_nc_wipe_done=0
|
||||||
|
|||||||
Reference in New Issue
Block a user