mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
Fix deletion of wrong backup directory on the backup server with alpine system
This commit is contained in:
parent
72978889ef
commit
ae41243324
@ -22,7 +22,8 @@ KUBECONFIG=${KUBECONFIG:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubeco
|
||||
BACKUP_DATE=$(date "+%F_%H-%M-%S")
|
||||
BACKUP_FOLDER=${BACKUP_FOLDER:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/backup/${BACKUP_DATE}}
|
||||
|
||||
# create backup fodler
|
||||
printf "Backup folder name: %s\n" $BACKUP_DATE
|
||||
# create backup folder
|
||||
mkdir -p ${BACKUP_FOLDER}
|
||||
|
||||
# cluster maintenance mode on && Neo4j maintenance mode on
|
||||
|
||||
@ -81,15 +81,16 @@ do
|
||||
cd $path
|
||||
|
||||
printf "In\n '$path'\n remove:\n"
|
||||
# TODO: replace 'ls' by 'find . -type d -maxdepth 1'? description: https://unix.stackexchange.com/questions/28939/how-to-delete-the-oldest-directory-in-a-given-directory
|
||||
while [ `ls -1 | wc -l` -gt $keep ]; do
|
||||
oldest=`ls -c1 | head -1`
|
||||
echo " $oldest"
|
||||
while [ `ls -1 | wc -l` -gt $keep ]; do
|
||||
# TODO: because 'ls' is not always relyable maybe replace 'ls' by 'find . -type d -maxdepth 1'? description: https://unix.stackexchange.com/questions/28939/how-to-delete-the-oldest-directory-in-a-given-directory
|
||||
# I tested this, but 'find' this is crutial, because of shell compatibilities
|
||||
oldest=`ls -c1 | sort -n | head -1`
|
||||
printf " %s\n" $oldest
|
||||
rm -rf $oldest
|
||||
done
|
||||
|
||||
printf "Keep the last %d backups:\n " $BACKUP_SAVED_BACKUPS_NUMBER
|
||||
ls
|
||||
printf "Keep the last %d backups:\n" $BACKUP_SAVED_BACKUPS_NUMBER
|
||||
ls -c1 | sort -n | awk '{print " " $0}'
|
||||
|
||||
cd $SCRIPT_DIR
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user